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

IOS Sign Up E2E Test #2422

Merged
merged 43 commits into from
Jan 3, 2025
Merged

IOS Sign Up E2E Test #2422

merged 43 commits into from
Jan 3, 2025

Conversation

Yuki-YuXin
Copy link
Contributor

@Yuki-YuXin Yuki-YuXin commented Dec 12, 2024

Proposed changes

  • Modify MSALNativeAuthEndToEndBaseTestCase to use different way of initialization depends on the parameter of customSubdomainFormat
  • Finish the sign up test cases according to: IOS Test plan

2.1.11 - test_signUpWithCode_withPasswordConfiguration_succeeds()
1.1.10 - test_signUpWithEmailPassword_andAgainSameEmail_fails()
1.1.11 - test_signUpWithEmailPassword_socialAccount_fails() - environment not ready
1.1.12 - test_signUpWithEmailPassword_invalidEmail_fails
1.1.13 - test_signUpWithEmailPassword_invalidPassword_fails
1.1.2 - test_signUpWithEmailPassword_resendEmail_success
1.1.5 - test_signUpWithEmailOTP_andSetPasswordAfterOTP_success
2.1.5 - test_signUpWithEmailOTP_resendEmail_success
2.1.6 - test_signUpWithEmailOTP_andExistingAccount
2.1.7 - test_signUpWithEmailPassword_socialAccount_fails - environment not ready
2.1.8 - test_signUpWithEmailPassword_invalidEmailFormat_fails

Web fallback test to automate:
Verify Custom URL Domain - Sign In
test_signInCustomDomain1InSuccess
test_signInCustomDomain2InSuccess
test_signInCustomDomain3InSuccess

Type of change

  • Feature work
  • Bug fix
  • Documentation
  • Engineering change
  • Test
  • Logging/Telemetry

Risk

  • High – Errors could cause MAJOR regression of many scenarios. (Example: new large features or high level infrastructure changes)
  • Medium – Errors could cause regression of 1 or more scenarios. (Example: somewhat complex bug fixes, small new features)
  • Small – No issues are expected. (Example: Very small bug fixes, string changes, or configuration settings changes)

@Yuki-YuXin Yuki-YuXin requested a review from a team as a code owner December 12, 2024 17:50
@Yuki-YuXin Yuki-YuXin added the native-auth Code related to native authentication label Dec 12, 2024
@@ -37,6 +37,11 @@ class MSALNativeAuthEndToEndBaseTestCase: XCTestCase {
static let signInEmailPasswordMFAUsernameKey = "sign_in_email_password_mfa_username"

Choose a reason for hiding this comment

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

This pull request does not update CHANGELOG.md.

Please consider if this change would be noticeable to a partner or user and either update CHANGELOG.md or resolve this conversation.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling custom domain formats and error conditions.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account checks, invalid email formats, and password configurations.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthSignInUserNameAndPasswordEndToEndTests.swift: Added tests for custom domain sign-in scenarios.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated to support custom subdomain formats and added helper methods for custom tenant subdomains.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom domain formats.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account checks, and invalid email formats.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including invalid email/password formats and OTP resend.
  • MSALNativeAuthSignInUserNameAndPasswordEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated client application initialization to support custom subdomain formats.

@Yuki-YuXin Yuki-YuXin removed the skip-native-auth-e2e-tests Only include this if Native Auth E2E tests are blocking the PR validation label Dec 18, 2024
@@ -129,4 +171,15 @@ class MSALNativeAuthEndToEndBaseTestCase: XCTestCase {
return Constants.clientIdEmailCodeAttributesKey
}
}

private func getCustomTenantSubdomain(tenantName: String, tenantId: String, format: AuthorityURLFormat) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please call this method getAuthotityURLString ? It seems more accurate.

Suggested change
private func getCustomTenantSubdomain(tenantName: String, tenantId: String, format: AuthorityURLFormat) -> String {
private func getAuthotityURLString(tenantSubdomain: String, tenantId: String, format: AuthorityURLFormat) -> String {

And could you please use tenantSubdomain instead of tenantName. They are two different properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -125,4 +125,130 @@ final class MSALNativeAuthSignInUsernameEndToEndTests: MSALNativeAuthEndToEndBas
XCTAssertNotNil(signInVerifyCodeDelegateSpy.result?.idToken)
XCTAssertEqual(signInVerifyCodeDelegateSpy.result?.account.username, username)
}

// Sign In - Verify Custom URL Domain - "https://<tenantName>.ciamlogin.com/<tenantName>.onmicrosoft.com"
func test_signInCustomDomain1InSuccess() async throws {
Copy link
Contributor

@nilo-ms nilo-ms Dec 19, 2024

Choose a reason for hiding this comment

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

Can you please include the name of the authority URL format in use instead of a number? Same comment applies for other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpPasswordErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
Copy link
Contributor

@nilo-ms nilo-ms Dec 19, 2024

Choose a reason for hiding this comment

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

Try to never use ! to force unwrap an optional. This can cause a crash and stop the execution of all tests

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
XCTAssertEqual(signUpStartDelegate.error?.isInvalidUsername, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done and modify and check all the sign up cases. error!.isBrowserRequired needs to use ! instead of ?. The others use ?.


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpPasswordErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
XCTAssertEqual(signUpStartDelegate.error?.isInvalidUsername, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpPasswordErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isInvalidPassword, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isInvalidPassword, true)
XCTAssertEqual(signUpStartDelegate.error?.isInvalidPassword, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isUserAlreadyExists, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isUserAlreadyExists, true)
XCTAssertEqual(signUpStartDelegate.error?.isUserAlreadyExists, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpPasswordErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
XCTAssertEqual(signUpStartDelegate.error?.isInvalidUsername, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Verify error condition
XCTAssertTrue(signUpStartDelegate.onSignUpPasswordErrorCalled)
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XCTAssertEqual(signUpStartDelegate.error!.isInvalidUsername, true)
XCTAssertEqual(signUpStartDelegate.error?.isInvalidUsername, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Sign In - Verify Custom URL Domain - "https://<tenantName>.ciamlogin.com/<tenantName>.onmicrosoft.com"
func test_signInCustomDomain1InSuccess() async throws {
guard let sut = initialisePublicClientApplication(clientIdType: .code, customAuthorityURLFormat: AuthorityURLFormat.tenantSubdomainLongVersion), let username = retrieveUsernameForSignInCode() else {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can avoid specifying the Enum name here :)

Suggested change
guard let sut = initialisePublicClientApplication(clientIdType: .code, customAuthorityURLFormat: AuthorityURLFormat.tenantSubdomainLongVersion), let username = retrieveUsernameForSignInCode() else {
guard let sut = initialisePublicClientApplication(clientIdType: .code, customAuthorityURLFormat: .tenantSubdomainLongVersion), let username = retrieveUsernameForSignInCode() else {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

// Hero Scenario 2.1.11. Sign up – Server requires password authentication, which is supported by the developer
// The same as 1.1.4
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is the same as the 1.1.4 why we're duplicating this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Repeat confirmation on the duplication. I will remove the test case but keep the comment for future tracking.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios in the MSAL Native Auth module.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account checks, invalid email format, and unsupported password authentication.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for custom URL domain sign-in scenarios.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios including resend OTP, invalid email/password, and existing account checks.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated initialisePublicClientApplication to support custom authority URL formats.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end test cases for sign-up and sign-in functionalities, including various edge cases and custom URL domain verifications.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account scenarios, invalid email formats, and unsupported authentication challenges.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid credentials.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Enhanced client application initialization to support custom authority URL formats.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of custom URL domains and error conditions.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, invalid email formats, and unsupported password authentication.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated initialisePublicClientApplication to support custom authority URL formats.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated client application initialization to support custom authority URL formats.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for custom URL domain sign-in scenarios.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated client application initialization to support custom authority URL formats.

AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Enhanced client application initialization to support custom authority URL formats.

1 similar comment
@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for custom URL domain sign-in scenarios.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated client application initialization to support custom authority URL formats.

AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Enhanced client application initialization to support custom authority URL formats.

@ameyapat
Copy link
Contributor

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling custom URL domains and error conditions.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, invalid email formats, and unsupported password authentication.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated initialisePublicClientApplication to support custom authority URL formats.

@ameyapat
Copy link
Contributor

ameyapat commented Jan 3, 2025

Cloned PR for yuki/sign-up-e2e


AI description (iteration 1)

PR Classification

New feature

PR Summary

This pull request adds new end-to-end tests for various sign-up and sign-in scenarios, including handling of email OTP, password complexity, and custom URL domains.

  • MSALNativeAuthSignUpUsernameEndToEndTests.swift: Added tests for email OTP resend, existing account errors, and invalid email formats.
  • MSALNativeAuthSignInUsernameEndToEndTests.swift: Added tests for sign-in with custom URL domains.
  • MSALNativeAuthSignUpUsernameAndPasswordEndToEndTests.swift: Added tests for email and password sign-up scenarios, including OTP resend and invalid password complexity.
  • MSALNativeAuthEndToEndBaseTestCase.swift: Updated client application initialization to support custom authority URL formats.

@Yuki-YuXin Yuki-YuXin merged commit 04cab7c into dev Jan 3, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
native-auth Code related to native authentication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants