@@ -37,6 +37,7 @@ import static com.mongodb.ClusterFixture.getBinding
3737import static com.mongodb.ClusterFixture.createAsyncCluster
3838import static com.mongodb.ClusterFixture.createCluster
3939import static com.mongodb.ClusterFixture.isAuthenticated
40+ import static com.mongodb.ClusterFixture.serverVersionGreaterThan
4041import static com.mongodb.MongoCredential.createCredential
4142import static com.mongodb.MongoCredential.createScramSha1Credential
4243import static com.mongodb.MongoCredential.createScramSha256Credential
@@ -115,11 +116,28 @@ class ScramSha256AuthenticationSpecification extends Specification {
115116 [sha256Explicit],
116117 [bothImplicit],
117118 [bothExplicitSha1],
118- [bothExplicitSha256],
119- [sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256]
119+ [bothExplicitSha256]
120120 ]
121121 }
122122
123+ @IgnoreIf ({ serverVersionGreaterThan(' 5.0' ) })
124+ def ' test authentication and authorization with multiple credentials' () {
125+ given :
126+ def cluster = createCluster(
127+ [sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256])
128+
129+ when :
130+ new CommandReadOperation<Document > (' admin' ,
131+ new BsonDocumentWrapper<Document > (new Document (' dbstats' , 1 ), new DocumentCodec ()), new DocumentCodec ())
132+ .execute(new ClusterBinding (cluster, ReadPreference . primary(), ReadConcern . DEFAULT ))
133+
134+ then :
135+ noExceptionThrown()
136+
137+ cleanup :
138+ cluster. close()
139+ }
140+
123141 def ' test authentication and authorization async' () {
124142 given :
125143 def cluster = createAsyncCluster(credentials)
@@ -145,11 +163,31 @@ class ScramSha256AuthenticationSpecification extends Specification {
145163 [sha256Explicit],
146164 [bothImplicit],
147165 [bothExplicitSha1],
148- [bothExplicitSha256],
149- [sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256]
166+ [bothExplicitSha256]
150167 ]
151168 }
152169
170+ @IgnoreIf ({ serverVersionGreaterThan(' 5.0' ) })
171+ def ' test authentication and authorization with multiple credentials async' () {
172+ given :
173+ def cluster = createAsyncCluster(
174+ [sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256])
175+ def callback = new FutureResultCallback ()
176+
177+ when :
178+ // make this synchronous
179+ new CommandReadOperation<Document > (' admin' ,
180+ new BsonDocumentWrapper<Document > (new Document (' dbstats' , 1 ), new DocumentCodec ()), new DocumentCodec ())
181+ .executeAsync(new AsyncClusterBinding (cluster, ReadPreference . primary(), ReadConcern . DEFAULT ), callback)
182+ callback. get()
183+
184+ then :
185+ noExceptionThrown()
186+
187+ cleanup :
188+ cluster. close()
189+ }
190+
153191 def ' test authentication and authorization failure with wrong mechanism' () {
154192 given :
155193 def cluster = createCluster(credentials)
0 commit comments