-
Notifications
You must be signed in to change notification settings - Fork 67
SWIFT-429 Implement auth spec tests #333
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8fe2dff
passing all tests
kmahar 841f336
auth prose tests
kmahar d1fc371
update linuxmain
kmahar 22b778e
use enum for all mechanisms
kmahar 3734fa2
todo
kmahar cfbc6f3
fix unicode literal creation
kmahar c99edf8
Add TODO
kmahar d01a3e2
use SyncMongoClient
kmahar 93bf1b5
bump mongodb version on travis
kmahar b6b1207
Update .travis.yml
kmahar 10e7126
lint
kmahar 08d4812
skip prose tests on < 4.0
kmahar 3c00fe8
Add auth files to xcodeproj
kmahar 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
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 |
|---|---|---|
|
|
@@ -5,45 +5,33 @@ internal class ConnectionString { | |
| /// Pointer to the underlying `mongoc_uri_t`. | ||
| internal let _uri: OpaquePointer | ||
|
|
||
| /// Initializes a new `ConnectionString` with the provided options. Updates `options` to correctly reflect the | ||
| /// final options set on the `ConnectionString`. | ||
| internal init(_ connectionString: String, options: inout ClientOptions) throws { | ||
| /// Initializes a new `ConnectionString` with the provided options. | ||
| internal init(_ connectionString: String, options: ClientOptions? = nil) throws { | ||
| var error = bson_error_t() | ||
| guard let uri = mongoc_uri_new_with_error(connectionString, &error) else { | ||
| throw extractMongoError(error: error) | ||
| } | ||
| self._uri = uri | ||
|
|
||
| if let rc = options.readConcern { | ||
| if let rc = options?.readConcern { | ||
| self.readConcern = rc | ||
| } | ||
| options.readConcern = self.readConcern | ||
|
|
||
| if let wc = options.writeConcern { | ||
| if let wc = options?.writeConcern { | ||
| self.writeConcern = wc | ||
| } | ||
| options.writeConcern = self.writeConcern | ||
|
|
||
| if let rp = options.readPreference { | ||
| if let rp = options?.readPreference { | ||
| self.readPreference = rp | ||
| } | ||
| options.readPreference = self.readPreference | ||
|
|
||
| if let rw = options.retryWrites { | ||
| if let rw = options?.retryWrites { | ||
| mongoc_uri_set_option_as_bool(self._uri, MONGOC_URI_RETRYWRITES, rw) | ||
| } | ||
| if let rr = options.retryReads { | ||
| mongoc_uri_set_option_as_bool(self._uri, MONGOC_URI_RETRYREADS, rr) | ||
| } | ||
|
|
||
| // we can't get values for retryReads and retryWrites individually, so we will read | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the client doesn't get the options struct back anymore, and doesn't actually care what the values of retryReads and retryWrites are, so we don't need to worry about retrieving those values anymore to send back. |
||
| // them out from the full doc here instead. | ||
| guard let opts = mongoc_uri_get_options(self._uri) else { | ||
| return | ||
| if let rr = options?.retryReads { | ||
| mongoc_uri_set_option_as_bool(self._uri, MONGOC_URI_RETRYREADS, rr) | ||
| } | ||
| let optsDoc = Document(copying: opts) | ||
| options.retryReads = optsDoc["retryreads"] as? Bool | ||
| options.retryWrites = optsDoc["retrywrites"] as? Bool | ||
| } | ||
|
|
||
| /// Cleans up the underlying `mongoc_uri_t`. | ||
|
|
||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason I wrote this clunky
inoutAPI where the connection string would update the client options struct to reflect the final values on the URI so that theMongoClientcould have correct values for read concern, write concern, and read preference.however, it's way simpler to just have
MongoClientread back those values by calling the appropriate getters on the connection string after it creates it (seeMongoClient.init.)