-
Notifications
You must be signed in to change notification settings - Fork 0
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
[34253] - Add AuthorizationControllerWrapper & Unit Test for TwilioPasskey iOS. #21
base: dev
Are you sure you want to change the base?
[34253] - Add AuthorizationControllerWrapper & Unit Test for TwilioPasskey iOS. #21
Conversation
e80eb42
to
de93987
Compare
// Then | ||
when (result) { | ||
is CreatePasskeyResult.Success -> { | ||
fail("It shouldn't succeed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line detected, which is longer than the defined maximum line length in the code style. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a false positive
…wilioPasskey iOS.
de93987
to
375997d
Compare
@@ -84,7 +84,7 @@ class AuthenticationManager: NSObject, ObservableObject { | |||
) { | |||
Task { | |||
do { | |||
let result = try await worker.registrationVerification(request: .init( | |||
_ = try await worker.registrationVerification(request: .init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something that can be checked in the verification response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah definitely makes sense, I added a validation to check if the response was verified by the backend. Thank you.
"name": "Example" | ||
}, | ||
"user": { | ||
"id": "WUU0ZmQzYWFmNGU0NTMyNGQwZjNlMTM0NjA3YjIxOTEyYg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be flaged as a secret, could you please change them to a placeholder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely 😅, added Placeholder prefix just to avoid any confusion. But apart from that the length must be exact. Thank you
* @property deviceUtils The utility class for device-related operations. | ||
*/ | ||
class AuthorizationControllerWrapper : IAuthorizationControllerWrapper { | ||
private var authController: ASAuthorizationController? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a lateinit var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, seems way clear with that one. Thank you
Generated by 🚫 Danger |
Generated by 🚫 Danger |
🧛 shared module Code Coverage:
|
File | Coverage |
---|---|
TwilioPasskey.kt |
97.38% |
Modified Files Not Found In Coverage Report:
AuthenticationManager.swift
AuthorizationControllerWrapper.kt
AuthorizationControllerWrapperMock.kt
PayloadMocks.kt
TwilioPasskeyTest.kt
Codebase cunningly covered by count Shroud 🧛
Generated by 🚫 Danger
Generated by 🚫 Danger |
*/ | ||
actual class TwilioPasskey private constructor( | ||
actual class TwilioPasskey internal constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can mapToTwilioException
be part of this class instead of the wrapper? As it is a TwilioException, this could be more related to this class and the wrapper can pass the original error
"name": "Example" | ||
}, | ||
"user": { | ||
"id": "PLACEHOLDERIDWUU0ZmQzYWFmNGU0NTMyNGQwZjNlMTM0N", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be something like PLACEHOLDERID
without the letters? Or can the letters be ABCD....
instead of WUU0ZmQzY.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size of the userId is being validated, so it requires to have the same size, maybe we can try with PLACEHOLDERID
and spaces
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we can complete the values with ABCDEFG.......
, so it will be added as the alphabet (known order)
"name": "user1", | ||
"displayName": "User One" | ||
}, | ||
"challenge": "WUYwNDhkMWE3ZWMzYTJhNjk3MDA1OWMyNzY2YmJjN2UwZg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this can be flagged as a secret
const val TIMEOUT = 600000L | ||
val keyCredential = | ||
KeyCredential( | ||
id = "6ySmhJd6qGUMCthiqszyb4Od4U6TFn0v3DLz-1EZrNQ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be flagged as a secret
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for values below RAW_ID
, ATTESTATION_OBJECT
, AUTHENTICATE_CHALLENGE
, CLIENT_DATA_JSON_CREATE
, SIGNATURE
, USER_HANDLE
. If we can use placeholder without letters will be better, if we need the values encoded or following a format, we should use dummy values so they are not considered secrets
controller: ASAuthorizationController, | ||
didCompleteWithAuthorization: ASAuthorization, | ||
) { | ||
val credentialRegistration = didCompleteWithAuthorization.credential as ASAuthorizationPlatformPublicKeyCredentialRegistration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to pass the credentialRegistration
to TwilioPasskey and applying the logic below in TwilioPasskey
? AuthorizationControllerWrapper
could be in charge of completing the interaction / needed code for iOS authorization, but some logic can be kept in TwilioPasskey
, so it can be tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No unfortunately that ASAuthorizationPlatformPublicKeyCredentialRegistration
contains a couple of Objects that can't be initialized outside of Apple private logic. So It won't be possible to create that object from Scratch to use it as a mock.
Ticket
Github Issue
Description
Commit message
Screenshot
Testing