Skip to content

Commit 581ae2e

Browse files
committed
Test fixes
1 parent df3ef8d commit 581ae2e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

driver-core/src/main/com/mongodb/internal/authentication/GcpCredentialHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static CredentialInfo fetchGcpCredentialInfo(final String resource) {
5252
String endpoint = "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience="
5353
+ resource;
5454
Map<String, String> header = new HashMap<>();
55-
header.put("Metadata-Flavor", "Google");;
55+
header.put("Metadata-Flavor", "Google");
5656
String response = getHttpContents("GET", endpoint, header);
5757
return new CredentialInfo(
5858
new BsonString(response).getValue(),

driver-core/src/main/com/mongodb/internal/connection/OidcAuthenticator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public final class OidcAuthenticator extends SaslAuthenticator {
8080
AZURE_ENVIRONMENT, GCP_ENVIRONMENT, TEST_ENVIRONMENT);
8181
private static final List<String> SUPPORTS_TOKEN_RESOURCE = Arrays.asList(
8282
AZURE_ENVIRONMENT, GCP_ENVIRONMENT);
83+
private static final List<String> ALLOWS_USERNAME = Arrays.asList(
84+
AZURE_ENVIRONMENT);
8385

8486
private static final Duration CALLBACK_TIMEOUT = Duration.ofMinutes(5);
8587

@@ -622,7 +624,7 @@ public static void validateBeforeUse(final MongoCredential credential) {
622624
+ " must not be specified");
623625
}
624626
} else {
625-
if (userName != null) {
627+
if (userName != null && !ALLOWS_USERNAME.contains(providerName)) {
626628
throw new IllegalArgumentException("user name must not be specified when " + ENVIRONMENT_KEY + " is specified");
627629
}
628630
if (machineCallback != null) {

driver-core/src/test/unit/com/mongodb/ConnectionStringSpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ class ConnectionStringSpecification extends Specification {
601601
new ConnectionString('mongodb://jeff@localhost/?' +
602602
'authMechanism=GSSAPI' +
603603
'&authMechanismProperties=' +
604-
'SERVICE_NAME:foo:bar')
604+
'SERVICE_NAMEbar') // missing =
605605

606606
then:
607607
thrown(IllegalArgumentException)

0 commit comments

Comments
 (0)