<commit_before>var assert = require('assert'),
	config = require('../config'),
	nitrogen = require('../../lib');

describe('principal', function() {

    var service = new nitrogen.Service(config);

    var camera = new nitrogen.Device({
        capabilities: "camera",
        nickname: "camera"
    });

    it('should be able to create and save a user', function(done) {
        var user = new nitrogen.User({
            nickname: "user",
            password: "<PASSWORD>"
        });

        user.email = "user" + Math.random() * 1000000 + "@<EMAIL>";
        user.name = "<NAME>";

        assert.equal(user.nickname, 'user');
        assert.equal(user.type, 'user');

        // clear the principal first so we are not just testing loading from it.
        service.store.set('principal.user', null);
        service.create(user, function(err, session, principal) {
            assert.equal(err, null);

            assert.equal(!principal.id, false);
            assert.equal(!principal.email, false);
            assert.equal(!principal.nickname, false);

            principal.name = "<NAME>";
            principal.email = "<EMAIL>";
            principal.save(session, function(err, p) {
                assert.ifError(err);

                assert.equal(p.name, "<NAME>");
                assert.notEqual(p.email, "<EMAIL>");

                // authentication ops should not pass password through.
                assert.equal(p.password, undefined);
<commit_msg>principals that have admin rights can do what they want.<commit_after>var assert = require('assert'),
	config = require('../config'),
	nitrogen = require('../../lib');

describe('principal', function() {

    var service = new nitrogen.Service(config);

    var camera = new nitrogen.Device({
        capabilities: "camera",
        nickname: "camera"
    });

    it('should be able to create and save a user', function(done) {
        var user = new nitrogen.User({
            nickname: "user",
            password: "<PASSWORD>"
        });

        user.email = "user" + Math.random() * 1000000 + "@gmail.com";
        user.name = "<NAME>";

        assert.equal(user.nickname, 'user');
        assert.equal(user.type, 'user');

        // clear the principal first so we are not just testing loading from it.
        service.store.set('principal.user', null);
        service.create(user, function(err, session, principal) {
            assert.equal(err, null);

            assert.equal(!principal.id, false);
            assert.equal(!principal.email, false);
            assert.equal(!principal.nickname, false);

            principal.name = "<NAME>";
            principal.save(session, function(err, p) {
                assert.ifError(err);

                assert.equal(p.name, "<NAME>");

                // authentication ops should not pass password through.
                assert.equal(p.password, undefined);

{'fraction_non_alphanumeric': 0.14413484692122464, 'fraction_numerical': 0.004815961472308222, 'mean_word_length': 2.1746724890829694, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6852554', 'n_tokens_mistral': 809, 'n_tokens_neox': 764, 'n_words': 201}