diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index 332faa86d4c25..870f701bce5ca 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -1248,12 +1249,9 @@ public String getId() { @Override public void addCredential(Credential credential) { - execute( - DriverCommand.ADD_CREDENTIAL, - Stream.concat( - credential.toMap().entrySet().stream(), - Stream.of(Map.entry("authenticatorId", id))) - .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue))); + Map map = new HashMap<>(credential.toMap()); + map.put("authenticatorId", id); + execute(DriverCommand.ADD_CREDENTIAL, map); } @Override diff --git a/java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java b/java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java index b7759733956f9..90794ec2b8e9e 100644 --- a/java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java +++ b/java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java @@ -189,6 +189,7 @@ void testAddNonResidentCredential() { Credential.createNonResidentCredential( credentialId, "localhost", privateKey, /* signCount= */ 0); authenticator.addCredential(credential); + authenticator.getCredentials(); // Attempt to use the credential to generate an assertion. Object response = getAssertionFor(Arrays.asList(1, 2, 3, 4)); @@ -215,6 +216,7 @@ void testAddNonResidentCredentialWhenAuthenticatorUsesU2FProtocol() { Credential.createNonResidentCredential( credentialId, "localhost", privateKey, /* signCount= */ 0); authenticator.addCredential(credential); + authenticator.getCredentials(); // Attempt to use the credential to generate an assertion. Object response = getAssertionFor(Arrays.asList(1, 2, 3, 4)); @@ -231,6 +233,7 @@ void testAddResidentCredential() { Credential.createResidentCredential( credentialId, "localhost", privateKey, userHandle, /* signCount= */ 0); authenticator.addCredential(credential); + authenticator.getCredentials(); // Attempt to use the credential to generate an assertion. Notice we use an // empty allowCredentials array. @@ -265,6 +268,7 @@ void testAddResidentCredentialNotSupportedWhenAuthenticatorUsesU2FProtocol() { Credential.createResidentCredential( credentialId, "localhost", privateKey, userHandle, /* signCount= */ 0); authenticator.addCredential(credential); + authenticator.getCredentials(); }); }