diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index 6c176e34dad07..be43ffa1515f4 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; @@ -1223,12 +1224,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 38c5938d706e0..61921710847b2 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(); List credentialList = authenticator.getCredentials(); assertThat(credentialList.size()).isEqualTo(1); @@ -216,6 +217,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)); @@ -232,6 +234,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. @@ -266,6 +269,7 @@ void testAddResidentCredentialNotSupportedWhenAuthenticatorUsesU2FProtocol() { Credential.createResidentCredential( credentialId, "localhost", privateKey, userHandle, /* signCount= */ 0); authenticator.addCredential(credential); + authenticator.getCredentials(); }); }