diff --git a/common b/common index 4bfba984b..6f369214c 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 4bfba984b59c300adb1c43a837ae8101fa4b77da +Subproject commit 6f369214cf3c6e44153d2a4eed1ff5b5bbf803a7 diff --git a/msal/build.gradle b/msal/build.gradle index a68187e4d..24ce6cd36 100644 --- a/msal/build.gradle +++ b/msal/build.gradle @@ -5,6 +5,9 @@ plugins { id 'checkstyle' id 'maven-publish' id 'kotlin-android' + + // Test retries + id 'org.gradle.test-retry' version '1.5.6' } apply from: 'versioning/version_tasks.gradle' @@ -25,6 +28,18 @@ codeCoverageReport { coverage.enabled = enableCodeCoverage } +// https://blog.gradle.org/gradle-flaky-test-retry-plugin +tasks.withType(Test) { + retry { + // The maximum number of test failures that are allowed before retrying is disabled. + maxRetries = 2 + // The maximum number of times to retry an individual test. + maxFailures = 10 + // Controls whether tests that initially fail and then pass on retry should fail the task. + failOnPassedAfterRetry = false + } +} + android { namespace "com.microsoft.identity.msal" compileOptions { diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571345.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571345.java deleted file mode 100644 index e71e3e887..000000000 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571345.java +++ /dev/null @@ -1,165 +0,0 @@ -// 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.msal.automationapp.testpass.broker.ltw; - -import androidx.annotation.NonNull; - -import com.microsoft.identity.client.msal.automationapp.R; -import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; -import com.microsoft.identity.client.ui.automation.annotations.LTWTests; -import com.microsoft.identity.client.ui.automation.annotations.RetryOnFailure; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; -import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; -import com.microsoft.identity.client.ui.automation.app.MsalTestApp; -import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; -import com.microsoft.identity.client.ui.automation.broker.BrokerLTW; -import com.microsoft.identity.client.ui.automation.interaction.FirstPartyAppPromptHandlerParameters; -import com.microsoft.identity.client.ui.automation.interaction.PromptParameter; -import com.microsoft.identity.client.ui.automation.interaction.microsoftsts.MicrosoftStsPromptHandlerParameters; -import com.microsoft.identity.labapi.utilities.client.LabQuery; -import com.microsoft.identity.labapi.utilities.constants.TempUserType; -import com.microsoft.identity.labapi.utilities.constants.UserType; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.List; - -// Samsung GA Coverage -// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571345 -@LTWTests -@RunOnAPI29Minus -@SupportedBrokers(brokers = {BrokerLTW.class}) -@RetryOnFailure -@RunWith(Parameterized.class) -public class TestCase2571345 extends AbstractMsalBrokerTest { - - private final UserType mUserType; - - public TestCase2571345(@NonNull UserType userType) { - mUserType = userType; - } - - @Parameterized.Parameters(name = "{0}") - public static List userType() { - return Arrays.asList( - UserType.MSA, - UserType.CLOUD - ); - } - @Test - public void test_2571345_LTW_SamsungGACoverage() throws Throwable{ - final String username = mLabAccount.getUsername(); - final String password = mLabAccount.getPassword(); - - mBroker.install(); - - // Install new OneAuthTestApp - final OneAuthTestApp oneAuthTestApp = new OneAuthTestApp(); - oneAuthTestApp.install(); - oneAuthTestApp.launch(); - oneAuthTestApp.handleFirstRunBasedOnUserType(mUserType); - - final FirstPartyAppPromptHandlerParameters promptHandlerParametersOneAuth = FirstPartyAppPromptHandlerParameters.builder() - .broker(mBroker) - .prompt(PromptParameter.LOGIN) - .loginHint(username) - .consentPageExpected(false) - .speedBumpExpected(false) - .sessionExpected(false) - .expectingBrokerAccountChooserActivity(false) - .expectingLoginPageAccountPicker(false) - .enrollPageExpected(false) - .build(); - // Click on sign in button, prompted to enter username and password - oneAuthTestApp.addFirstAccount(username, password, promptHandlerParametersOneAuth); - oneAuthTestApp.confirmAccount(username); - - // Install new MsalTestApp - final MsalTestApp msalTestApp = new MsalTestApp(); - msalTestApp.install(); - msalTestApp.launch(); - msalTestApp.handleFirstRunBasedOnUserType(mUserType); - - final MicrosoftStsPromptHandlerParameters promptHandlerParametersMsal = MicrosoftStsPromptHandlerParameters.builder() - .prompt(PromptParameter.SELECT_ACCOUNT) - .loginHint(username) - .sessionExpected(false) - .broker(mBroker) - .expectingBrokerAccountChooserActivity(false) - .expectingProvidedAccountInBroker(false) - .expectingLoginPageAccountPicker(false) - .expectingProvidedAccountInCookie(false) - .consentPageExpected(false) - .passwordPageExpected(false) - .speedBumpExpected(false) - .registerPageExpected(false) - .enrollPageExpected(false) - .staySignedInPageExpected(false) - .verifyYourIdentityPageExpected(false) - .howWouldYouLikeToSignInExpected(false) - .build(); - - // Add login hint as the username and Click on AcquireToken button - // NOT prompted for credentials. - msalTestApp.handleUserNameInput(username); - final String token = msalTestApp.acquireToken(username, password, promptHandlerParametersMsal, false); - Assert.assertNotNull(token); - - // Click on "Get Active Broker Pkg Name" button - //The response msg should show LTW's pkg name - msalTestApp.handleBackButton(); - final String activeBroker = msalTestApp.getActiveBrokerPackageName(); - Assert.assertEquals("Active broker pkg name : " + BrokerLTW.BROKER_LTW_APP_PACKAGE_NAME, activeBroker); - } - - @Override - public LabQuery getLabQuery() { - return LabQuery.builder() - .userType(mUserType) - .build(); - } - - @Override - public TempUserType getTempUserType() { - return null; - } - - @Override - public String[] getScopes() { - return new String[]{"User.read"}; - } - - @Override - public String getAuthority() { - return mApplication.getConfiguration().getDefaultAuthority().getAuthorityURL().toString(); - } - - @Override - public int getConfigFileResourceId() { - return R.raw.msal_config_default; - } -} diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571361.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571361.java index 4f9764b24..dcaaa9d44 100644 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571361.java +++ b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571361.java @@ -28,7 +28,6 @@ import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; import com.microsoft.identity.client.ui.automation.annotations.LTWTests; import com.microsoft.identity.client.ui.automation.annotations.RetryOnFailure; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; import com.microsoft.identity.client.ui.automation.app.MsalTestApp; import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; @@ -52,7 +51,6 @@ // If Company Portal is installed after LTW, user should still get SSO // https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571361 @LTWTests -@RunOnAPI29Minus @RetryOnFailure @SupportedBrokers(brokers = {BrokerLTW.class}) @RunWith(Parameterized.class) diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571508.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571508.java deleted file mode 100644 index 364a978ca..000000000 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2571508.java +++ /dev/null @@ -1,173 +0,0 @@ -// 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.msal.automationapp.testpass.broker.ltw; - -import androidx.annotation.NonNull; - -import com.microsoft.identity.client.msal.automationapp.AbstractMsalUiTest; -import com.microsoft.identity.client.msal.automationapp.R; -import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; -import com.microsoft.identity.client.ui.automation.annotations.LTWTests; -import com.microsoft.identity.client.ui.automation.annotations.RetryOnFailure; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; -import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; -import com.microsoft.identity.client.ui.automation.app.MsalTestApp; -import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; -import com.microsoft.identity.client.ui.automation.broker.BrokerLTW; -import com.microsoft.identity.client.ui.automation.broker.BrokerMicrosoftAuthenticator; -import com.microsoft.identity.client.ui.automation.interaction.FirstPartyAppPromptHandlerParameters; -import com.microsoft.identity.client.ui.automation.interaction.PromptParameter; -import com.microsoft.identity.client.ui.automation.interaction.microsoftsts.MicrosoftStsPromptHandlerParameters; -import com.microsoft.identity.labapi.utilities.client.LabQuery; -import com.microsoft.identity.labapi.utilities.constants.TempUserType; -import com.microsoft.identity.labapi.utilities.constants.UserType; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.List; - -// If LTW without broker is installed, updated MSAL should still get SSO -// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571508 -@LTWTests -@RunOnAPI29Minus -@RetryOnFailure -@SupportedBrokers(brokers = {BrokerMicrosoftAuthenticator.class}) -@RunWith(Parameterized.class) -public class TestCase2571508 extends AbstractMsalBrokerTest { - - private final UserType mUserType; - - public TestCase2571508(@NonNull UserType userType) { - mUserType = userType; - } - - @Parameterized.Parameters(name = "{0}") - public static List userType() { - return Arrays.asList( - UserType.MSA, - UserType.CLOUD - ); - } - - @Test - public void test_2571508_LTW_IfBrokerlessLTWInstalledMsalShouldHaveSSO() throws Throwable { - final String username = mLabAccount.getUsername(); - final String password = mLabAccount.getPassword(); - - // Install old LTW - final BrokerLTW brokerLTW = new BrokerLTW(BrokerLTW.OLD_BROKER_LTW_APK, BrokerLTW.BROKER_LTW_APK); - brokerLTW.install(); - - // AcquireToken interactively on OneAuthTestApp - final OneAuthTestApp oneAuthTestApp = new OneAuthTestApp(); - oneAuthTestApp.install(); - oneAuthTestApp.launch(); - oneAuthTestApp.handleFirstRunBasedOnUserType(mUserType); - - final FirstPartyAppPromptHandlerParameters promptHandlerParametersOneAuth = FirstPartyAppPromptHandlerParameters.builder() - .broker(mBroker) - .prompt(PromptParameter.LOGIN) - .loginHint(username) - .consentPageExpected(false) - .speedBumpExpected(false) - .sessionExpected(false) - .expectingBrokerAccountChooserActivity(false) - .expectingLoginPageAccountPicker(false) - .enrollPageExpected(false) - .build(); - // Click on sign in button, prompted to enter username and password - oneAuthTestApp.addFirstAccount(username, password, promptHandlerParametersOneAuth); - oneAuthTestApp.confirmAccount(username); - - // Install new MSALTestApp - final MsalTestApp msalTestApp = new MsalTestApp(); - msalTestApp.install(); - msalTestApp.launch(); - msalTestApp.handleFirstRunBasedOnUserType(mUserType); - - Assert.assertTrue(mBroker instanceof BrokerMicrosoftAuthenticator); - - final MicrosoftStsPromptHandlerParameters promptHandlerParametersMsal = MicrosoftStsPromptHandlerParameters.builder() - .prompt(PromptParameter.SELECT_ACCOUNT) - .loginHint(username) - .sessionExpected(false) - .broker(null) - .expectingBrokerAccountChooserActivity(false) - .expectingProvidedAccountInBroker(false) - .expectingLoginPageAccountPicker(false) - .expectingProvidedAccountInCookie(false) - .consentPageExpected(false) - .passwordPageExpected(false) - .speedBumpExpected(false) - .registerPageExpected(false) - .enrollPageExpected(false) - .staySignedInPageExpected(false) - .verifyYourIdentityPageExpected(false) - .howWouldYouLikeToSignInExpected(false) - .build(); - - // Add login hint as the username and Click on AcquireToken button - // NOT prompted for credentials. - msalTestApp.handleUserNameInput(username); - - // Click on "Get Active Broker Pkg Name" button - // return Authenticator app package name - final String activeBroker = msalTestApp.getActiveBrokerPackageName(); - Assert.assertEquals("Active broker pkg name : " + BrokerMicrosoftAuthenticator.AUTHENTICATOR_APP_PACKAGE_NAME, activeBroker); - msalTestApp.handleBackButton(); - - final String token = msalTestApp.acquireToken(username, password, promptHandlerParametersMsal, false); - Assert.assertNotNull(token); - } - - @Override - public LabQuery getLabQuery() { - return LabQuery.builder() - .userType(mUserType) - .build(); - } - - @Override - public TempUserType getTempUserType() { - return null; - } - - @Override - public String[] getScopes() { - return new String[]{"User.read"}; - } - - @Override - public String getAuthority() { - return mApplication.getConfiguration().getDefaultAuthority().getAuthorityURL().toString(); - } - - @Override - public int getConfigFileResourceId() { - return R.raw.msal_config_default; - } -} diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2572249.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2572249.java index 67e9fbff7..8a62e324d 100644 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2572249.java +++ b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2572249.java @@ -28,7 +28,6 @@ import com.microsoft.identity.client.msal.automationapp.R; import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; import com.microsoft.identity.client.ui.automation.annotations.LTWTests; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; import com.microsoft.identity.client.ui.automation.app.MsalTestApp; import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; @@ -51,7 +50,6 @@ // Updated LTW, Updated Auth app and uninstall LTW // https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2572249 @LTWTests -@RunOnAPI29Minus @SupportedBrokers(brokers = {BrokerLTW.class}) @RunWith(Parameterized.class) public class TestCase2572249 extends AbstractMsalBrokerTest { diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582290.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582290.java index 7b1b299d4..69a2f0ef9 100644 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582290.java +++ b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582290.java @@ -27,7 +27,6 @@ import com.microsoft.identity.client.msal.automationapp.R; import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; import com.microsoft.identity.client.ui.automation.annotations.LTWTests; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; import com.microsoft.identity.client.ui.automation.app.MsalTestApp; import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; @@ -51,7 +50,6 @@ // If LTW is the active broker, and request is made through Authenticator from MSAL in non-shared device mode, nothing should break // https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2582290 @LTWTests -@RunOnAPI29Minus @SupportedBrokers(brokers = {BrokerLTW.class}) @RunWith(Parameterized.class) public class TestCase2582290 extends AbstractMsalBrokerTest { diff --git a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582291.java b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582291.java index 9abf263ef..32de86c2b 100644 --- a/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582291.java +++ b/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/ltw/TestCase2582291.java @@ -27,7 +27,6 @@ import com.microsoft.identity.client.msal.automationapp.R; import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest; import com.microsoft.identity.client.ui.automation.annotations.LTWTests; -import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus; import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers; import com.microsoft.identity.client.ui.automation.app.MsalTestApp; import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp; @@ -51,7 +50,6 @@ // If LTW is the active broker, and request is made through CP from MSAL in non-shared device mode, nothing should break // https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2582291 @LTWTests -@RunOnAPI29Minus @SupportedBrokers(brokers = {BrokerLTW.class}) @RunWith(Parameterized.class) public class TestCase2582291 extends AbstractMsalBrokerTest {