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

« back to all changes in this revision

Viewing changes to jstests/auth/auth_helpers.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.auth() shell helper.
 
2
 
 
3
var conn = MongoRunner.runMongod({ smallfiles: "", auth: "" });
 
4
 
 
5
var mechanisms, hasMongoCR, hasCramMd5;
 
6
 
 
7
// Find out if this build supports the authenticationMechanisms startup parameter.  If it does,
 
8
// restart with MONGODB-CR and CRAM-MD5 mechanisms enabled.
 
9
var cmdOut = conn.getDB('admin').runCommand({getParameter: 1, authenticationMechanisms: 1})
 
10
if (cmdOut.ok) {
 
11
    MongoRunner.stopMongod(conn);
 
12
    conn = MongoRunner.runMongod({ restart: conn,
 
13
                                   setParameter: "authenticationMechanisms=MONGODB-CR,CRAM-MD5" });
 
14
    mechanisms = [ "MONGODB-CR", "CRAM-MD5" ];
 
15
    hasMongoCR = true;
 
16
    hasCramMd5 = true;
 
17
    print("test info: Enabling non-default authentication mechanisms.");
 
18
}
 
19
else {
 
20
    mechanisms = [ "MONGODB-CR" ];
 
21
    hasMongoCR = true;
 
22
    hasCramMd5 = false;
 
23
    print("test info: Using only default authentication mechanism, MONGODB-CR.");
 
24
}
 
25
 
 
26
var admin = conn.getDB('admin');
 
27
 
 
28
var testedSomething = false;
 
29
 
 
30
admin.addUser('andy', 'a');
 
31
 
 
32
// If the server supports them MONGODB-CR, try all the ways to call db.auth that use MONGODB-CR.
 
33
if (hasMongoCR) {
 
34
    testedSomething = true;
 
35
    assert(admin.auth('andy', 'a'));
 
36
    admin.logout();
 
37
    assert(admin.auth({user: 'andy', pwd: 'a'}));
 
38
    admin.logout();
 
39
    assert(admin.auth({mechanism: 'MONGODB-CR', user: 'andy', pwd: 'a'}));
 
40
    admin.logout();
 
41
}
 
42
 
 
43
// If the server supports CRAM-MD5, try it out.
 
44
if (hasCramMd5) {
 
45
    testedSomething = true;
 
46
    assert(admin.auth({mechanism: 'CRAM-MD5', user: 'andy', pwd: 'a'}));
 
47
    admin.logout();
 
48
}
 
49
 
 
50
// Sanity check that we tested at least one of MONGODB-CR and CRAM-MD5.
 
51
assert(testedSomething, "No candidate authentication mechanisms matched.");
 
52
 
 
53
// Invalid mechanisms shouldn't lead to authentication, but also shouldn't crash.
 
54
assert(!admin.auth({mechanism: 'this-mechanism-is-fake', user: 'andy', pwd: 'a'}));