Skip to content

Commit 3d6a757

Browse files
authored
chore: Using the new sendVerificationCode API (#54)
1 parent 1f9514e commit 3d6a757

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

Package.resolved

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/Authenticator/States/VerifyUserState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class VerifyUserState: AuthenticatorBaseState {
3737

3838
do {
3939
log.verbose("Attempting to verify user attribute \(key)")
40-
let result = try await authenticationService.resendConfirmationCode(
40+
let result = try await authenticationService.sendVerificationCode(
4141
forUserAttributeKey: key,
4242
options: nil
4343
)

Tests/AuthenticatorTests/Mocks/MockAuthenticationService.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ class MockAuthenticationService: AuthenticationService {
122122
throw AuthenticatorError.error(message: "Unable to resend confirmation code for attribute")
123123
}
124124

125+
var sendVerificationCodeForAttributeCount = 0
126+
var mockedSendVerificationCodeForAttributeResult: AuthCodeDeliveryDetails?
127+
func sendVerificationCode(forUserAttributeKey userAttributeKey: AuthUserAttributeKey, options: AuthSendUserAttributeVerificationCodeRequest.Options?) async throws -> AuthCodeDeliveryDetails {
128+
sendVerificationCodeForAttributeCount += 1
129+
if let mockedSendVerificationCodeForAttributeResult = mockedSendVerificationCodeForAttributeResult {
130+
return mockedSendVerificationCodeForAttributeResult
131+
}
132+
133+
throw AuthenticatorError.error(message: "Unable to send verification code for attribute")
134+
}
135+
125136
var confirmUserAttributeCount = 0
126137
var mockedConfirmUserAttributeError: AuthenticatorError?
127138
func confirm(userAttribute: AuthUserAttributeKey, confirmationCode: String, options: AuthConfirmUserAttributeRequest.Options?) async throws {

Tests/AuthenticatorTests/States/VerifyUserStateTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class VerifyUserStateTests: XCTestCase {
3434

3535
func testVerifyUser_withSuccess_shouldSetNextStep() async throws {
3636
let destination = DeliveryDestination.email("[email protected]")
37-
authenticationService.mockedResendConfirmationCodeForAttributeResult = .init(destination: destination)
37+
authenticationService.mockedSendVerificationCodeForAttributeResult = .init(destination: destination)
3838
let task = Task { @MainActor in
3939
state.selectedField = .email
4040
}
4141
await task.value
4242
try await state.verifyUser()
43-
XCTAssertEqual(authenticationService.resendConfirmationCodeForAttributeCount, 1)
43+
XCTAssertEqual(authenticationService.sendVerificationCodeForAttributeCount, 1)
4444
XCTAssertEqual(authenticatorState.setCurrentStepCount, 1)
4545
let currentStep = try XCTUnwrap(authenticatorState.setCurrentStepValue)
4646
guard case .confirmVerifyUser(let attribute, let deliveryDetails) = currentStep else {

0 commit comments

Comments
 (0)