Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> map = new HashMap<>(credential.toMap());
map.put("authenticatorId", id);
execute(DriverCommand.ADD_CREDENTIAL, map);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want Map.copyOf(map) here to ensure immutability? Not certain it matters.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void testAddNonResidentCredential() {
Credential.createNonResidentCredential(
credentialId, "localhost", privateKey, /* signCount= */ 0);
authenticator.addCredential(credential);
authenticator.getCredentials();

List<Credential> credentialList = authenticator.getCredentials();
assertThat(credentialList.size()).isEqualTo(1);
Expand Down Expand Up @@ -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));
Expand All @@ -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.
Expand Down Expand Up @@ -266,6 +269,7 @@ void testAddResidentCredentialNotSupportedWhenAuthenticatorUsesU2FProtocol() {
Credential.createResidentCredential(
credentialId, "localhost", privateKey, userHandle, /* signCount= */ 0);
authenticator.addCredential(credential);
authenticator.getCredentials();
});
}

Expand Down
Loading