Skip to content

Commit

Permalink
fix the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoshouzi-gh committed Apr 2, 2024
1 parent a35b791 commit f4497cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions FirebaseAuth/Sources/User/FIRUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ - (void)startPasskeyEnrollmentWithName:(nullable NSString *)name
// cached the passkey name. This is needed when calling
// finalizePasskeyEnrollment
self.passkeyName = name;
// If passkey name is not provided, we will provide a firebase formatted
// default name.
if (self.passkeyName == nil || [self.passkeyName isEqual:@""]) {
self.passkeyName = @"Unnamed account (Apple)";
}
NSData *challengeInData =
[[NSData alloc] initWithBase64EncodedString:response.challenge
options:0];
Expand All @@ -631,7 +636,7 @@ - (void)startPasskeyEnrollmentWithName:(nullable NSString *)name
ASAuthorizationPlatformPublicKeyCredentialRegistrationRequest *request =
[provider
createCredentialRegistrationRequestWithChallenge:challengeInData
name:name
name:self.passkeyName
userID:userIdInData];
completion(request, nil);
}
Expand All @@ -654,10 +659,6 @@ - (void)finalizePasskeyEnrollmentWithPlatformCredential:
NSString *attestationObject =
[platformCredential.rawAttestationObject base64EncodedStringWithOptions:0];

// If passkey name is not provided, we will provide a firebase formatted default name.
if (self.passkeyName == nil || [self.passkeyName isEqual:@""]) {
self.passkeyName = @"Unnamed account (Apple)";
}
FIRFinalizePasskeyEnrollmentRequest *request =
[[FIRFinalizePasskeyEnrollmentRequest alloc] initWithIDToken:self.rawAccessToken
name:self.passkeyName
Expand Down
7 changes: 7 additions & 0 deletions FirebaseAuth/Tests/Unit/FIRUserTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,9 @@ - (void)testStartPasskeyEnrollmentWithNilNameSuccess {
XCTAssertEqualObjects(
user.passkeyName,
kDefaultPasskeyName);
XCTAssertEqualObjects(
request.name,
kDefaultPasskeyName);
XCTAssertEqualObjects(
[[request challenge]
base64EncodedStringWithOptions:
Expand Down Expand Up @@ -1083,11 +1086,15 @@ - (void)testStartPasskeyEnrollmentWithEmptyNameSuccess {
XCTAssertEqualObjects(
user.passkeyName,
kDefaultPasskeyName);
XCTAssertEqualObjects(
request.name,
kDefaultPasskeyName);
XCTAssertEqualObjects(
[[request challenge]
base64EncodedStringWithOptions:
0],
kChallenge);

XCTAssertEqualObjects(
[request
relyingPartyIdentifier],
Expand Down

0 comments on commit f4497cd

Please sign in to comment.