summaryrefslogtreecommitdiff
path: root/jstests/auth
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2019-03-18 14:52:38 -0400
committerJonathan Reams <jbreams@mongodb.com>2019-03-26 11:11:47 -0400
commit0a847ef8453015e8b622595692b2fde0488486a6 (patch)
tree884c3a1f5387429413b2ff2fa706e16c000d8f42 /jstests/auth
parentd9d6f2d08a8539b4288185165729d5ded205f142 (diff)
downloadmongo-0a847ef8453015e8b622595692b2fde0488486a6.tar.gz
SERVER-39820 Include client IP in log message for successful authentication
Diffstat (limited to 'jstests/auth')
-rw-r--r--jstests/auth/logs_include_client_info.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/jstests/auth/logs_include_client_info.js b/jstests/auth/logs_include_client_info.js
new file mode 100644
index 00000000000..5e793100686
--- /dev/null
+++ b/jstests/auth/logs_include_client_info.js
@@ -0,0 +1,29 @@
+// This test just checks that the success/failure messages for authentication include the IP
+// address of the client attempting to authenticate.
+
+(function() {
+ const conn = MongoRunner.runMongod({auth: ""});
+ const admin = conn.getDB("admin");
+
+ admin.createUser({
+ user: "root",
+ pwd: "root",
+ roles: ["root"],
+ });
+
+ assert(admin.auth("root", "root"));
+
+ const failConn = new Mongo(conn.host);
+ failConn.getDB("admin").auth("root", "toot");
+
+ const log = assert.commandWorked(admin.runCommand({getLog: "global"})).log;
+
+ const successRegex =
+ /Successfully authenticated as principal root on admin from client (?:\d{1,3}\.){3}\d{1,3}:\d+/;
+ const failRegex =
+ /SASL SCRAM-SHA-\d+ authentication failed for root on admin from client (?:\d{1,3}\.){3}\d{1,3}:\d+/;
+
+ assert(log.some((line) => successRegex.test(line)));
+ assert(log.some((line) => failRegex.test(line)));
+ MongoRunner.stopMongod(conn);
+})();