Skip to content

Commit 94b5292

Browse files
committed
rename for clarity
1 parent 509782e commit 94b5292

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

test/integration/auth/mongodb_oidc.prose.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ describe('OIDC Auth Spec Tests', function () {
550550
describe('4.4 Speculative Authentication should be ignored on Reauthentication', function () {
551551
let utilClient: MongoClient;
552552
const callbackSpy = sinon.spy(createCallback());
553-
const commands = [];
553+
const saslStarts = [];
554554
// - Create an OIDC configured client.
555555
// - Populate the *Client Cache* with a valid access token to enforce Speculative Authentication.
556556
// - Perform an `insert` operation that succeeds.
@@ -584,9 +584,8 @@ describe('OIDC Auth Spec Tests', function () {
584584
monitorCommands: true
585585
});
586586
client.on('commandStarted', event => {
587-
console.log(event);
588587
if (event.commandName === 'saslStart') {
589-
commands.push(event);
588+
saslStarts.push(event);
590589
}
591590
});
592591
const provider = client.s.authProviders.getOrCreateProvider('MONGODB-OIDC', {
@@ -595,18 +594,21 @@ describe('OIDC Auth Spec Tests', function () {
595594
const token = await readFile(path.join(process.env.OIDC_TOKEN_DIR, 'test_user1'), {
596595
encoding: 'utf8'
597596
});
597+
598598
provider.workflow.cache.put({ accessToken: token });
599599
collection = client.db('test').collection('test');
600+
600601
await collection.insertOne({ name: 'test' });
601602
expect(callbackSpy).to.not.have.been.called;
602-
expect(commands).to.be.empty;
603+
expect(saslStarts).to.be.empty;
603604

604605
utilClient = new MongoClient(uriSingle, {
605606
authMechanismProperties: {
606607
OIDC_CALLBACK: createCallback()
607608
},
608609
retryReads: false
609610
});
611+
610612
await utilClient
611613
.db()
612614
.admin()
@@ -633,7 +635,7 @@ describe('OIDC Auth Spec Tests', function () {
633635
it('successfully authenticates', async function () {
634636
await collection.insertOne({ name: 'test' });
635637
expect(callbackSpy).to.have.been.calledOnce;
636-
expect(commands.length).to.equal(1);
638+
expect(saslStarts.length).to.equal(1);
637639
});
638640
});
639641
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Command Logging and Monitoring
2+
3+
______________________________________________________________________
4+
5+
## Testing
6+
7+
### Automated Tests
8+
9+
There are tests in the [Unified Test Format](../../unified-test-format/unified-test-format.md) for both logging and
10+
monitoring in `/logging` and `monitoring`, respectively. Drivers MUST run the logging tests with their max document
11+
length setting (as described in the [logging specification](../../logging/logging.md#configurable-max-document-length))
12+
set to a large value e.g. 10,000; this is necessary in order for the driver to emit the full server reply (and to allow
13+
matching against that reply) on certain MongoDB versions and topologies.
14+
15+
### Prose Tests
16+
17+
Drivers MUST implement the following logging prose tests. These tests require the ability to capture log message data in
18+
a structured form as described in the
19+
[Unified Test Format specification](../../unified-test-format/unified-test-format.md#expectedLogMessage).
20+
21+
Note: the following tests mention string "length"; this refers to length in terms of whatever unit the driver has chosen
22+
to support for specifying max document length as discussed in the
23+
[logging specification](../../logging/logging.md#configurable-max-document-length).
24+
25+
*Test 1: Default truncation limit*
26+
27+
1. Configure logging with a minimum severity level of "debug" for the "command" component. Do not explicitly configure
28+
the max document length.
29+
2. Construct an array `docs` containing the document `{"x" : "y"}` repeated 100 times.
30+
3. Insert `docs` to a collection via `insertMany`.
31+
4. Inspect the resulting "command started" log message and assert that the "command" value is a string of length 1000 +
32+
(length of trailing ellipsis).
33+
5. Inspect the resulting "command succeeded" log message and assert that the "reply" value is a string of length \<=
34+
1000 + (length of trailing ellipsis).
35+
6. Run `find()` on the collection where the document was inserted.
36+
7. Inspect the resulting "command succeeded" log message and assert that the reply is a string of length 1000 + (length
37+
of trailing ellipsis).
38+
39+
*Test 2: Explicitly configured truncation limit*
40+
41+
1. Configure logging with a minimum severity level of "debug" for the "command" component. Set the max document length
42+
to 5.
43+
2. Run the command `{"hello": true}`.
44+
3. Inspect the resulting "command started" log message and assert that the "command" value is a string of length 5 +
45+
(length of trailing ellipsis).
46+
4. Inspect the resulting "command succeeded" log message and assert that the "reply" value is a string of length 5 +
47+
(length of trailing ellipsis).
48+
5. If the driver attaches raw server responses to failures and can access these via log messages to assert on, run the
49+
command `{"notARealCommand": true}`. Inspect the resulting "command failed" log message and confirm that the server
50+
error is a string of length 5 + (length of trailing ellipsis).
51+
52+
*Test 3: Truncation with multi-byte codepoints*
53+
54+
A specific test case is not provided here due to the allowed variations in truncation logic as well as varying extended
55+
JSON whitespace usage. Drivers MUST write language-specific tests that confirm truncation of commands, replies, and (if
56+
applicable) server responses included in error messages work as expected when the data being truncated includes
57+
multi-byte Unicode codepoints. If the driver uses anything other than Unicode codepoints as the unit for max document
58+
length, there also MUST be tests confirming that cases where the max length falls in the middle of a multi-byte
59+
codepoint are handled gracefully.

0 commit comments

Comments
 (0)