diff options
author | Adam Rayner <adam.rayner@mongodb.com> | 2023-05-12 16:10:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-15 18:38:23 +0000 |
commit | 54ce9f3a48dcde0758e4cdf77d7b0efd08d71e2b (patch) | |
tree | e176978340351503ca811e07832e35446ceaa9a3 | |
parent | b45d9b1215bedf4328bded55913475dd6b589e92 (diff) | |
download | mongo-54ce9f3a48dcde0758e4cdf77d7b0efd08d71e2b.tar.gz |
SERVER-76961: update expected log struct for abandoned session, add deterministic test for abandoned authentication session
-rw-r--r-- | jstests/auth/authn_session_abandoned.js | 31 | ||||
-rw-r--r-- | jstests/auth/speculative-auth-replset.js | 5 |
2 files changed, 34 insertions, 2 deletions
diff --git a/jstests/auth/authn_session_abandoned.js b/jstests/auth/authn_session_abandoned.js new file mode 100644 index 00000000000..d5298ecbe02 --- /dev/null +++ b/jstests/auth/authn_session_abandoned.js @@ -0,0 +1,31 @@ +// Test for auth counters in serverStatus. + +(function() { +'use strict'; +load('jstests/libs/parallel_shell_helpers.js'); + +const kFailedToAuthMsgId = 5286307; + +const mongod = MongoRunner.runMongod(); + +try { + mongod.getDB("admin").createUser( + {"user": "admin", "pwd": "pwd", roles: ['root'], mechanisms: ["SCRAM-SHA-256"]}); + + const shellCmd = () => { + // base64 encoded: 'n,,n=admin,r=deadbeefcafeba11'; + const kClientPayload = 'biwsbj1hZG1pbixyPWRlYWRiZWVmY2FmZWJhMTE='; + + db.getSiblingDB("admin").runCommand( + {saslStart: 1, mechanism: "SCRAM-SHA-256", payload: kClientPayload}); + }; + + startParallelShell(shellCmd, mongod.port)(); + + assert.soon(() => checkLog.checkContainsOnceJson( + mongod, kFailedToAuthMsgId, {"result": ErrorCodes.AuthenticationAbandoned})); + +} finally { + MongoRunner.stopMongod(mongod); +} +})(); diff --git a/jstests/auth/speculative-auth-replset.js b/jstests/auth/speculative-auth-replset.js index 9f36444a020..3bd960780d6 100644 --- a/jstests/auth/speculative-auth-replset.js +++ b/jstests/auth/speculative-auth-replset.js @@ -27,8 +27,9 @@ function countAuthInLog(conn) { } } else if (entry.id === kAuthenticationFailedLogId) { // Authentication can fail legitimately because the secondary abandons the connection - // during shutdown. - assert.eq(entry.attr.error.code, ErrorCodes.AuthenticationAbandoned); + // during shutdown - if we do encounter an authentication failure in the log, make sure + // that it is only of this type, fail anything else + assert.eq(entry.attr.result, ErrorCodes.AuthenticationAbandoned); } else { // Irrelevant. return; |