Skip to content

Commit

Permalink
Skip tests of multiple credentials on servers > 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jyemin committed Apr 12, 2022
1 parent d7acfc6 commit 72a399f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
Expand Up @@ -37,6 +37,7 @@ import static com.mongodb.ClusterFixture.getBinding
import static com.mongodb.ClusterFixture.createAsyncCluster
import static com.mongodb.ClusterFixture.createCluster
import static com.mongodb.ClusterFixture.isAuthenticated
import static com.mongodb.ClusterFixture.serverVersionGreaterThan
import static com.mongodb.MongoCredential.createCredential
import static com.mongodb.MongoCredential.createScramSha1Credential
import static com.mongodb.MongoCredential.createScramSha256Credential
Expand Down Expand Up @@ -115,11 +116,28 @@ class ScramSha256AuthenticationSpecification extends Specification {
[sha256Explicit],
[bothImplicit],
[bothExplicitSha1],
[bothExplicitSha256],
[sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256]
[bothExplicitSha256]
]
}

@IgnoreIf({ serverVersionGreaterThan('5.0') })
def 'test authentication and authorization with multiple credentials'() {
given:
def cluster = createCluster(
[sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256])

when:
new CommandReadOperation<Document>('admin',
new BsonDocumentWrapper<Document>(new Document('dbstats', 1), new DocumentCodec()), new DocumentCodec())
.execute(new ClusterBinding(cluster, ReadPreference.primary(), ReadConcern.DEFAULT))

then:
noExceptionThrown()

cleanup:
cluster.close()
}

def 'test authentication and authorization async'() {
given:
def cluster = createAsyncCluster(credentials)
Expand All @@ -145,11 +163,31 @@ class ScramSha256AuthenticationSpecification extends Specification {
[sha256Explicit],
[bothImplicit],
[bothExplicitSha1],
[bothExplicitSha256],
[sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256]
[bothExplicitSha256]
]
}

@IgnoreIf({ serverVersionGreaterThan('5.0') })
def 'test authentication and authorization with multiple credentials async'() {
given:
def cluster = createAsyncCluster(
[sha1Implicit, sha1Explicit, sha256Implicit, sha256Explicit, bothImplicit, bothExplicitSha1, bothExplicitSha256])
def callback = new FutureResultCallback()

when:
// make this synchronous
new CommandReadOperation<Document>('admin',
new BsonDocumentWrapper<Document>(new Document('dbstats', 1), new DocumentCodec()), new DocumentCodec())
.executeAsync(new AsyncClusterBinding(cluster, ReadPreference.primary(), ReadConcern.DEFAULT), callback)
callback.get()

then:
noExceptionThrown()

cleanup:
cluster.close()
}

def 'test authentication and authorization failure with wrong mechanism'() {
given:
def cluster = createCluster(credentials)
Expand Down
Expand Up @@ -35,6 +35,7 @@ import static Fixture.getMongoClientURI
import static com.mongodb.ClusterFixture.isAuthenticated
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet
import static com.mongodb.ClusterFixture.serverVersionAtLeast
import static com.mongodb.ClusterFixture.serverVersionGreaterThan
import static com.mongodb.Fixture.getMongoClient
import static com.mongodb.MongoCredential.createCredential

Expand Down Expand Up @@ -325,7 +326,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
readConcern << [ReadConcern.DEFAULT, ReadConcern.LOCAL, ReadConcern.MAJORITY]
}

@IgnoreIf({ !serverVersionAtLeast(3, 6) || !isAuthenticated() })
@IgnoreIf({ (!serverVersionAtLeast(3, 6) || !isAuthenticated()) || serverVersionGreaterThan('5.0') })
@SuppressWarnings('deprecation')
def 'should not use a default session when there is more than one authenticated user'() {
given:
Expand Down

0 comments on commit 72a399f

Please sign in to comment.