Skip to content

Commit 5aab10c

Browse files
nvborisenkosandeepsuryaprasad
authored andcommitted
[dotnet] Fix webauth credential to allow nullable rpID (SeleniumHQ#15201)
1 parent 0e90a2d commit 5aab10c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

dotnet/src/webdriver/VirtualAuth/Credential.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public sealed class Credential
3434
private readonly byte[] id;
3535
private readonly byte[]? userHandle;
3636

37-
private Credential(byte[] id, bool isResidentCredential, string rpId, string privateKey, byte[]? userHandle, int signCount)
37+
private Credential(byte[] id, bool isResidentCredential, string? rpId, string privateKey, byte[]? userHandle, int signCount)
3838
{
3939
this.id = id ?? throw new ArgumentNullException(nameof(id));
4040
this.IsResidentCredential = isResidentCredential;
41-
this.RpId = rpId ?? throw new ArgumentNullException(nameof(rpId));
41+
this.RpId = rpId;
4242
this.PrivateKey = privateKey ?? throw new ArgumentNullException(nameof(privateKey));
4343
this.userHandle = userHandle;
4444
this.SignCount = signCount;
@@ -52,7 +52,7 @@ private Credential(byte[] id, bool isResidentCredential, string rpId, string pri
5252
/// <param name="privateKey">The private Key for the credentials.</param>
5353
/// <param name="signCount">The signature counter for the credentials.</param>
5454
/// <returns>The created instance of the Credential class.</returns>
55-
/// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
55+
/// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
5656
public static Credential CreateNonResidentCredential(byte[] id, string rpId, string privateKey, int signCount)
5757
{
5858
return new Credential(id, false, rpId, privateKey, null, signCount);
@@ -67,7 +67,7 @@ public static Credential CreateNonResidentCredential(byte[] id, string rpId, str
6767
/// <param name="userHandle">The user handle associated to the credential.</param>
6868
/// <param name="signCount">The signature counter for the credentials.</param>
6969
/// <returns>The created instance of the Credential class.</returns>
70-
/// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
70+
/// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
7171
public static Credential CreateResidentCredential(byte[] id, string rpId, string privateKey, byte[] userHandle, int signCount)
7272
{
7373
return new Credential(id, true, rpId, privateKey, userHandle, signCount);
@@ -86,7 +86,7 @@ public static Credential CreateResidentCredential(byte[] id, string rpId, string
8686
/// <summary>
8787
/// Gets the ID of the relying party of this credential.
8888
/// </summary>
89-
public string RpId { get; }
89+
public string? RpId { get; }
9090

9191
/// <summary>
9292
/// Gets the private key of the credential.
@@ -130,7 +130,10 @@ public Dictionary<string, object> ToDictionary()
130130

131131
toReturn["credentialId"] = Base64UrlEncoder.Encode(this.id);
132132
toReturn["isResidentCredential"] = this.IsResidentCredential;
133-
toReturn["rpId"] = this.RpId;
133+
if (this.RpId is not null)
134+
{
135+
toReturn["rpId"] = this.RpId;
136+
}
134137
toReturn["privateKey"] = this.PrivateKey;
135138
toReturn["signCount"] = this.SignCount;
136139
if (this.userHandle is not null)

dotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public void ShouldRemoveAllCredentials()
479479
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Virtual Authenticator")]
480480
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Virtual Authenticator")]
481481
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Virtual Authenticator")]
482-
public void testSetUserVerified()
482+
public void TestSetUserVerified()
483483
{
484484
CreateRKEnabledCTAP2Authenticator();
485485

0 commit comments

Comments
 (0)