-
Notifications
You must be signed in to change notification settings - Fork 920
GODRIVER-3544, GODRIVER-3653 Allow Client to Send Client Metadata On-Demand #2197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matthewdale
merged 15 commits into
mongodb:master
from
prestonvasquez:feature/godriver-3544-metadata-on-demand
Oct 17, 2025
+1,737
−329
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6590f6e
Allow appending client metadata
prestonvasquez 751104f
Finish prose tests
prestonvasquez 9373c48
Use BSON document literals to define the expected metadata documents.
matthewdale 8d6b75d
Use statically-defined expected metadata documents for all tests.
matthewdale f0bc695
Merge branch 'master' into feature/godriver-3544-metadata-on-demand
matthewdale bc9a413
Fix TestAuthenticateToAnything and reduce calls to atomic.Pointer.Load
matthewdale 74be46f
Move assert.EqualBSON to the assertbson package and use it instead of…
matthewdale 8b483fd
Fix appending client metadata for authenticated handshakes.
matthewdale b9d57dd
Merge branch 'master' into feature/godriver-3544-metadata-on-demand
matthewdale 2cce6d6
Fix app name test.
matthewdale 551ff2e
Fix LB handshake test and PR feedback.
matthewdale 9fa6096
Fix AppendDriverInfo comment.
matthewdale 0785b0d
Fix non-LB handshake test.
matthewdale 11282cd
Update internal/assert/assertbson/assertbson_test.go
matthewdale 11797dc
Add test cases for assertbson.EqualValue
matthewdale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright (C) MongoDB, Inc. 2025-present. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. You may obtain | ||
| // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| package assertbsoncore | ||
|
|
||
| import ( | ||
| "errors" | ||
| "testing" | ||
|
|
||
| "go.mongodb.org/mongo-driver/v2/internal/assert" | ||
| "go.mongodb.org/mongo-driver/v2/internal/handshake" | ||
| "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" | ||
| ) | ||
|
|
||
| // HandshakeClientMetadata compares the client metadata in two wire messages. It | ||
| // extracts the client metadata document from each wire message and compares | ||
| // them. If the document is not found, it assumes the wire message is just the | ||
| // value of the client metadata document itself. | ||
| func HandshakeClientMetadata(t testing.TB, expectedWM, actualWM []byte) bool { | ||
| gotCommand, err := handshake.ParseClientMetadata(actualWM) | ||
| if err != nil { | ||
| if errors.Is(err, bsoncore.ErrElementNotFound) { | ||
| // If the element is not found, the actual wire message may just be the | ||
| // client metadata document itself. | ||
| gotCommand = bsoncore.Document(actualWM) | ||
| } else { | ||
| return assert.Fail(t, "error parsing actual wire message: %v", err) | ||
| } | ||
| } | ||
|
|
||
| wantCommand, err := handshake.ParseClientMetadata(expectedWM) | ||
| if err != nil { | ||
| // If the element is not found, the expected wire message may just be the | ||
| // client metadata document itself. | ||
| if errors.Is(err, bsoncore.ErrElementNotFound) { | ||
| wantCommand = bsoncore.Document(expectedWM) | ||
| } else { | ||
| return assert.Fail(t, "error parsing expected wire message: %v", err) | ||
| } | ||
| } | ||
|
|
||
| return assert.Equal(t, wantCommand, gotCommand, | ||
| "expected: %v, got: %v", bsoncore.Document(wantCommand), bsoncore.Document(gotCommand)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.