~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to jstests/auth/adduser_helper.js

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Test the db.addUser() shell helper.
 
2
 
 
3
var passwordHash = function(username, password) {
 
4
    return hex_md5(username + ":mongo:" + password);
 
5
}
 
6
 
 
7
var conn = MongoRunner.runMongod({smallfiles: ""});
 
8
 
 
9
var db = conn.getDB('addUser');
 
10
db.dropDatabase();
 
11
 
 
12
jsTest.log("Testing creating backwards-compatible user objects using old form of db.addUser");
 
13
db.addUser('spencer', 'password');
 
14
assert.eq(1, db.system.users.count());
 
15
var userObj = db.system.users.findOne();
 
16
assert.eq('spencer', userObj['user']);
 
17
assert.eq(passwordHash('spencer', 'password'), userObj['pwd']);
 
18
 
 
19
// Should replace previous entry
 
20
db.addUser('spencer', 'newpassword', true);
 
21
assert.eq(1, db.system.users.count());
 
22
userObj = db.system.users.findOne();
 
23
assert.eq('spencer', userObj['user']);
 
24
assert.eq(passwordHash('spencer', 'newpassword'), userObj['pwd']);
 
25
assert(userObj['readOnly']);
 
26
 
 
27
 
 
28
 
 
29
jsTest.log("Testing new form of addUser");
 
30
 
 
31
// Can't create old-style entries with new addUser helper.
 
32
assert.throws(function() {db.addUser({user:'noroles', pwd:'password'});});
 
33
// Should fail because user already exists
 
34
assert.throws(function() {db.addUser({user:'spencer', pwd:'password', roles:'read'});});
 
35
 
 
36
// Create valid extended form user
 
37
db.addUser({user:'andy', pwd:'password', roles:['read']});
 
38
assert.eq(2, db.system.users.count());
 
39
userObj = db.system.users.findOne({user:'andy'});
 
40
assert.eq('andy', userObj['user']);
 
41
assert.eq(passwordHash('andy', 'password'), userObj['pwd']);
 
42
assert.eq('read', userObj['roles'][0]);
 
43
 
 
44
// Create valid extended form external user
 
45
db.addUser({user:'andy', userSource:'$sasl', roles:['readWrite']});
 
46
assert.eq(3, db.system.users.count());
 
47
userObj = db.system.users.findOne({user:'andy', userSource:'$sasl'});
 
48
assert.eq('andy', userObj['user']);
 
49
assert.eq('$sasl', userObj['userSource']);
 
50
assert.eq('readWrite', userObj['roles'][0]);
 
51
assert(!userObj['pwd']);
 
 
b'\\ No newline at end of file'