Skip to content

Commit 72a399f

Browse files
committed
Skip tests of multiple credentials on servers > 5.0
1 parent d7acfc6 commit 72a399f

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import static com.mongodb.ClusterFixture.getBinding
3737
import static com.mongodb.ClusterFixture.createAsyncCluster
3838
import static com.mongodb.ClusterFixture.createCluster
3939
import static com.mongodb.ClusterFixture.isAuthenticated
40+
import static com.mongodb.ClusterFixture.serverVersionGreaterThan
4041
import static com.mongodb.MongoCredential.createCredential
4142
import static com.mongodb.MongoCredential.createScramSha1Credential
4243
import 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)

driver-legacy/src/test/functional/com/mongodb/MongoClientSessionSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import static Fixture.getMongoClientURI
3535
import static com.mongodb.ClusterFixture.isAuthenticated
3636
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet
3737
import static com.mongodb.ClusterFixture.serverVersionAtLeast
38+
import static com.mongodb.ClusterFixture.serverVersionGreaterThan
3839
import static com.mongodb.Fixture.getMongoClient
3940
import static com.mongodb.MongoCredential.createCredential
4041

@@ -325,7 +326,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
325326
readConcern << [ReadConcern.DEFAULT, ReadConcern.LOCAL, ReadConcern.MAJORITY]
326327
}
327328

328-
@IgnoreIf({ !serverVersionAtLeast(3, 6) || !isAuthenticated() })
329+
@IgnoreIf({ (!serverVersionAtLeast(3, 6) || !isAuthenticated()) || serverVersionGreaterThan('5.0') })
329330
@SuppressWarnings('deprecation')
330331
def 'should not use a default session when there is more than one authenticated user'() {
331332
given:

0 commit comments

Comments
 (0)