Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing DeviceBinding NONE option on Simulators #308

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ class AA_05_DeviceBindingCallbackTest: CallbackBaseTest {
ex.fulfill()
})
waitForExpectations(timeout: 60, handler: nil)
if isSimulator {
XCTAssertEqual(bindingResult, "DeviceBinding/Signing is not supported on the iOS Simulator")
return
}

XCTAssertEqual(bindingResult, "Success")

Expand Down Expand Up @@ -301,10 +297,7 @@ class AA_05_DeviceBindingCallbackTest: CallbackBaseTest {
})
waitForExpectations(timeout: 60, handler: nil)

if isSimulator {
XCTAssertEqual(bindingResult, "DeviceBinding/Signing is not supported on the iOS Simulator")
return
}

XCTAssertEqual(bindingResult, "Success")

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ class AA_06_DeviceSigningVerifierCallbackTest: CallbackBaseTest {
ex.fulfill()
})
waitForExpectations(timeout: 60, handler: nil)
if isSimulator {
XCTAssertEqual(singningResult, DeviceBindingStatus.clientNotRegistered.errorMessage)
return
}

XCTAssertEqual(singningResult, "Success")
}
else {
Expand Down Expand Up @@ -294,10 +291,7 @@ class AA_06_DeviceSigningVerifierCallbackTest: CallbackBaseTest {
ex.fulfill()
})
waitForExpectations(timeout: 60, handler: nil)
if isSimulator {
XCTAssertEqual(singningResult, DeviceBindingStatus.clientNotRegistered.errorMessage)
return
}

XCTAssertEqual(singningResult, "Success")
}
else {
Expand Down Expand Up @@ -370,10 +364,7 @@ class AA_06_DeviceSigningVerifierCallbackTest: CallbackBaseTest {
ex.fulfill()
})
waitForExpectations(timeout: 60, handler: nil)
if isSimulator {
XCTAssertEqual(singningResult, DeviceBindingStatus.clientNotRegistered.errorMessage)
return
}

XCTAssertEqual(singningResult, "Authentication Timeout")
}
else {
Expand Down Expand Up @@ -719,10 +710,7 @@ class AA_06_DeviceSigningVerifierCallbackTest: CallbackBaseTest {
ex.fulfill()
})
waitForExpectations(timeout: 60, handler: nil)
if isSimulator {
XCTAssertEqual(bindingResult, "DeviceBinding/Signing is not supported on the iOS Simulator")
return
}

XCTAssertEqual(bindingResult, "Success")
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// DeviceBindingCallback.swift
// FRDeviceBinding
//
Expand Down Expand Up @@ -170,11 +170,14 @@ open class DeviceBindingCallback: MultipleValuesCallback, Binding {
deviceRepository: DeviceBindingRepository = LocalDeviceBindingRepository(),
prompt: Prompt? = nil,
_ completion: @escaping DeviceBindingResultCallback) {
if deviceBindingAuthenticationType != .none {
#if targetEnvironment(simulator)
// DeviceBinding/Signing is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
// DeviceBinding/Signing other than `.NONE` type is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
Copy link
Contributor

Choose a reason for hiding this comment

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

add some tests for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests were failing and fixed based on that

return
#endif
}

let authInterface = authInterface ?? getDeviceAuthenticator(type: deviceBindingAuthenticationType)
authInterface.initialize(userId: userId, prompt: prompt ?? Prompt(title: title, subtitle: subtitle, description: promptDescription))
let deviceId = deviceId ?? FRDevice.currentDevice?.identifier.getIdentifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ open class DeviceSigningVerifierCallback: MultipleValuesCallback, Binding {
customClaims: [String: Any] = [:],
prompt: Prompt? = nil,
_ completion: @escaping DeviceSigningResultCallback) {

if userKey.authType != .none {
#if targetEnvironment(simulator)
// DeviceBinding/Signing is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
// DeviceBinding/Signing other than `.NONE` type is not supported on the iOS Simulator
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add some tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests were failing and fixed based on that

Copy link
Contributor

@jeyanthanperiyasamy jeyanthanperiyasamy Oct 9, 2024

Choose a reason for hiding this comment

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

sorry didnt notice this test class update, when I add my comment, and at the same time u pushed.

handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
#endif
}

authInterface.initialize(userId: userKey.userId, prompt: prompt ?? Prompt(title: title, subtitle: subtitle, description: promptDescription))
guard authInterface.isSupported() else {
handleException(status: .unsupported(errorMessage: nil), completion: completion)
Expand Down
Loading