-
Notifications
You must be signed in to change notification settings - Fork 138
Android E2E Sign Up, Fixes AB#3073857 #2213
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
44afe84
Apply LoggerCheckHelper.kt (applied for those NativeAuthPublicClientA…
Yuki-YuXin 17f6a07
Update the NativeAuthPublicClientApplicationAbstractTest structure to…
Yuki-YuXin 3a1df81
Finish sign up otp
Yuki-YuXin b1150ff
Merge branch 'dev' into yuki/signup-e2e
Yuki-YuXin 18326e3
Remove ignore tag
Yuki-YuXin 839611a
Comment out the logger check
Yuki-YuXin 45b81a6
Clean up the name
Yuki-YuXin 145ff57
Remove logger
Yuki-YuXin 122b73c
Add loggerCheckHelper
Yuki-YuXin 43f9339
loggerCheck = setupLoggerCheckHelper()
Yuki-YuXin db78d7f
Double checking the work scopes have been all included
Yuki-YuXin a2da64d
Remove LoggerCheckHelper.kt experiment since it is out of scope
Yuki-YuXin 7178cec
Fix SignUpEmailPasswordTest.kt testSignInAfterSignUp()
Yuki-YuXin e897b06
Remove LoggerCheckHelper.kt
Yuki-YuXin 627ef91
Merge branch 'dev' into yuki/signup-e2e
Yuki-YuXin 91bac62
Remove @Ignore MFA
Yuki-YuXin 4b8c24c
Merge remote-tracking branch 'origin/yuki/signup-e2e' into yuki/signu…
Yuki-YuXin 6a1710d
Re-add the ignore tag because of the failure
Yuki-YuXin 242b66c
Address testResendCode comment and situation
Yuki-YuXin bd75314
ALl test cases apply new AbstractTest to extract configuration initia…
Yuki-YuXin 6027036
Merge branch 'dev' into yuki/signup-e2e
Yuki-YuXin c2e96b6
Remove overlap MFA test case
Yuki-YuXin 38f1f2d
Add config modification for the testSuccess, which causes the failure
Yuki-YuXin adc64bc
Merge branch 'dev' into yuki/signup-e2e
Yuki-YuXin fa13a6a
Address comments
Yuki-YuXin 5abc55e
Merge remote-tracking branch 'origin/yuki/signup-e2e' into yuki/signu…
Yuki-YuXin 4cfcce0
Use SIGN_IN_MFA_MULTI_AUTH config instead of SINGLE for the failed MF…
Yuki-YuXin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
...ient/e2e/tests/network/nativeauth/NativeAuthPublicClientApplicationAnotherAbstractTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // All rights reserved. | ||
| // | ||
| // This code is licensed under the MIT License. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files(the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions : | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| package com.microsoft.identity.client.e2e.tests.network.nativeauth | ||
|
|
||
| import android.app.Activity | ||
| import android.content.Context | ||
| import androidx.test.core.app.ApplicationProvider | ||
| import com.google.gson.Gson | ||
| import com.google.gson.reflect.TypeToken | ||
| import com.microsoft.identity.client.ILoggerCallback | ||
| import com.microsoft.identity.client.Logger | ||
| import com.microsoft.identity.client.PublicClientApplication | ||
| import com.microsoft.identity.client.e2e.shadows.ShadowAndroidSdkStorageEncryptionManager | ||
| import com.microsoft.identity.client.e2e.tests.IPublicClientApplicationTest | ||
| import com.microsoft.identity.client.exception.MsalException | ||
| import com.microsoft.identity.common.internal.controllers.CommandDispatcherHelper | ||
| import com.microsoft.identity.internal.testutils.TestUtils | ||
| import com.microsoft.identity.internal.testutils.labutils.KeyVaultFetchHelper | ||
| import com.microsoft.identity.internal.testutils.labutils.LabConstants | ||
| import com.microsoft.identity.internal.testutils.labutils.LabUserHelper | ||
| import com.microsoft.identity.internal.testutils.labutils.LabUserQuery | ||
| import com.microsoft.identity.internal.testutils.nativeauth.ConfigType | ||
| import com.microsoft.identity.internal.testutils.nativeauth.api.models.NativeAuthTestConfig | ||
| import com.microsoft.identity.nativeauth.INativeAuthPublicClientApplication | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.test.StandardTestDispatcher | ||
| import kotlinx.coroutines.test.setMain | ||
| import org.junit.After | ||
| import org.junit.Assert | ||
| import org.junit.Before | ||
| import org.junit.runner.RunWith | ||
| import org.mockito.Mockito | ||
| import org.robolectric.RobolectricTestRunner | ||
| import org.robolectric.annotation.Config | ||
| import org.robolectric.annotation.LooperMode | ||
|
|
||
| // TODO: move to "PAUSED". A work in RoboTestUtils will be needed though. | ||
| @LooperMode(LooperMode.Mode.LEGACY) | ||
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(shadows = [ShadowAndroidSdkStorageEncryptionManager::class]) | ||
| abstract class NativeAuthPublicClientApplicationAnotherAbstractTest : IPublicClientApplicationTest { | ||
Yuki-YuXin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| companion object{ | ||
| const val SHARED_PREFERENCES_NAME = "com.microsoft.identity.client.account_credential_cache" | ||
| const val INVALID_EMAIL = "invalid_email" | ||
| const val INVALID_PASSWORD = "invalid_password" | ||
| } | ||
|
|
||
| private lateinit var context: Context | ||
| private lateinit var activity: Activity | ||
|
|
||
| // Remove default Coroutine test timeout of 10 seconds. | ||
| private val testDispatcher = StandardTestDispatcher() | ||
|
|
||
| override fun getConfigFilePath(): String { | ||
| return "" // Not needed for native auth flows | ||
| } | ||
|
|
||
| @Before | ||
| open fun setup() { | ||
| context = ApplicationProvider.getApplicationContext() | ||
| activity = Mockito.mock(Activity::class.java) | ||
| Mockito.`when`(activity.applicationContext).thenReturn(context) | ||
| CommandDispatcherHelper.clear() | ||
| Dispatchers.setMain(testDispatcher) | ||
| } | ||
|
|
||
| @After | ||
| open fun cleanup() { | ||
| // remove everything from cache after test ends | ||
| TestUtils.clearCache(SHARED_PREFERENCES_NAME) | ||
| } | ||
|
|
||
| fun getSafePassword(): String { | ||
| val query = LabUserQuery() | ||
| query.federationProvider = LabConstants.FederationProvider.CIAM_CUD | ||
| query.signInAudience = LabConstants.SignInAudience.AZURE_AD_MY_ORG | ||
| val credential = LabUserHelper.getCredentials(query) | ||
| return credential.password | ||
| } | ||
|
|
||
| private fun getConfigsThroughSecretValue(): Map<String, NativeAuthTestConfig.Config>? { | ||
| val secretValue = KeyVaultFetchHelper.getSecretForBuildAutomation("msalandroidnativeauthautomationconfjsonfile") | ||
| val type = TypeToken.getParameterized( | ||
| Map::class.java, | ||
| String::class.java, | ||
| NativeAuthTestConfig.Config::class.java | ||
| ).type | ||
|
|
||
| return Gson().fromJson(secretValue, type) | ||
| } | ||
|
|
||
| fun getConfig(configType: ConfigType): NativeAuthTestConfig.Config { | ||
| val secretValue = getConfigsThroughSecretValue() | ||
| return secretValue?.get(configType.stringValue) | ||
| ?: throw IllegalStateException("Config not $secretValue") | ||
| } | ||
|
|
||
| fun setupPCA(config: NativeAuthTestConfig.Config, challengeTypes: List<String>): INativeAuthPublicClientApplication { | ||
| return try { | ||
| PublicClientApplication.createNativeAuthPublicClientApplication( | ||
| context, | ||
| config.clientId, | ||
| config.authorityUrl, | ||
| null, | ||
| challengeTypes | ||
| ) | ||
| } catch (e: MsalException) { | ||
| Assert.fail(e.message) | ||
| throw e | ||
| } | ||
| } | ||
|
|
||
| fun <T> retryOperation( | ||
| maxRetries: Int = 5, | ||
| authFlow: () -> T | ||
| ) { | ||
| var retryCount = 0 | ||
| var shouldRetry = true | ||
|
|
||
| while (shouldRetry) { | ||
| try { | ||
| authFlow() | ||
| shouldRetry = false // authFlow() has succeeded, so we don't need to retry. | ||
| } catch (e: Exception) { | ||
| //1secmail occasionally has a delay for emails to arrive / return from the API, or throws an internal server error, which causes tests to fail | ||
| //In this case, retry the test | ||
| if (retryCount >= maxRetries) { | ||
| Assert.fail(e.message) | ||
| shouldRetry = false | ||
| } else { | ||
| retryCount++ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.