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

Fadi/am tests #2206

Draft
wants to merge 18 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion common
Submodule common updated 0 files
9 changes: 8 additions & 1 deletion msalautomationapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ if (project.hasProperty("distMsalVersion")) {
msalVersion = distMsalVersion
}

// Used to check what flights are passed during pipeline runs
def copyOfLocalFlights = ""
if (project.hasProperty("localFlights")) {
copyOfLocalFlights = localFlights
}

android {

packagingOptions {
Expand Down Expand Up @@ -48,7 +54,7 @@ android {
defaultConfig {
multiDexEnabled true
namespace = "com.microsoft.identity.client.msal.automationapp"
applicationId "com.msft.identity.client.sample"
applicationId "com.msft.identity.client.msal.automationapp"
minSdkVersion rootProject.ext.automationAppMinSDKVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand All @@ -67,6 +73,7 @@ android {
buildConfigField("String", BROKER_LTW, "\"$BROKER_LTW\"")
buildConfigField("String", BROKER_HOST, "\"$BROKER_HOST\"")
buildConfigField("String", AUTO_BROKER, "\"$AUTO_BROKER\"")
buildConfigField("String", "COPY_OF_LOCAL_FLIGHTS_FOR_TEST_PURPOSES", "\"$copyOfLocalFlights\"")
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand All @@ -50,6 +51,7 @@
// Samsung GA Coverage
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571345
@LTWTests
@RetryOnFailure
@RunOnAPI29Minus
@SupportedBrokers(brokers = {BrokerLTW.class})
@RunWith(Parameterized.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void test_2571565() throws Throwable {
@Override
public LabQuery getLabQuery() {
return LabQuery.builder()
.userType(UserType.CLOUD)
.userType(mUserType)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerHost;
Expand All @@ -51,6 +52,7 @@
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2582292
@LTWTests
@SupportedBrokers(brokers = {BrokerLTW.class})
@RetryOnFailure
public class TestCase2582292 extends AbstractMsalBrokerTest {

@Test
Expand Down Expand Up @@ -86,7 +88,7 @@ public void test_2582292() throws LabApiException, InterruptedException, UiObjec
msalTestApp.launch();
msalTestApp.handleFirstRun();
try {
Thread.sleep(3000);
Thread.sleep(5000);
} catch (final InterruptedException e) {
throw new AssertionError(e);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerCompanyPortal;
Expand All @@ -51,6 +52,7 @@
@LTWTests
@SupportedBrokers(brokers = {BrokerMicrosoftAuthenticator.class})
@RunWith(Parameterized.class)
@RetryOnFailure
public class TestCase2584411 extends AbstractMsalBrokerTest {
private final UserType mUserType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerCompanyPortal;
Expand All @@ -51,6 +52,7 @@
@LTWTests
@SupportedBrokers(brokers = {BrokerCompanyPortal.class})
@RunWith(Parameterized.class)
@RetryOnFailure
public class TestCase2584412 extends AbstractMsalBrokerTest {
private final UserType mUserType;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.microsoft.identity.client.msal.automationapp.testpass.broker.ltw;

import androidx.annotation.NonNull;

import com.microsoft.identity.client.msal.automationapp.BuildConfig;
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.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerLTW;
import com.microsoft.identity.client.ui.automation.interaction.PromptParameter;
import com.microsoft.identity.client.ui.automation.interaction.microsoftsts.MicrosoftStsPromptHandlerParameters;
import com.microsoft.identity.client.ui.automation.utils.UiAutomatorUtils;
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.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.List;

// Sign in with AAD and MSA account
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/3029738
@LTWTests
@RetryOnFailure
@SupportedBrokers(brokers = {BrokerLTW.class})
@RunWith(Parameterized.class)
public class TestCase3029738 extends AbstractMsalBrokerTest {

private final UserType mUserType;

public TestCase3029738(@NonNull UserType userType) {
mUserType = userType;
}

@Parameterized.Parameters(name = "{0}")
public static List<UserType> userType() {
return Arrays.asList(
UserType.MSA,
UserType.CLOUD
);
}

@Test
public void test() throws Throwable {
// Check flight, this is checking what was passed to automation app, not the broker apks
Assume.assumeTrue( "EnableSystemAccountManager flight is not activated, Test will be skipped",
BuildConfig.COPY_OF_LOCAL_FLIGHTS_FOR_TEST_PURPOSES.contains("EnableSystemAccountManager:true"));

// Fetch account credentials
final String username = mLabAccount.getUsername();
final String password = mLabAccount.getPassword();

// Install and launch msal test app
// set configuration based on user type
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

// Prompt handler for the subsequent
final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
.loginHint(username)
.sessionExpected(false)
.broker(mBroker)
.expectingBrokerAccountChooserActivity(false)
.expectingProvidedAccountInBroker(false)
.expectingLoginPageAccountPicker(false)
.expectingProvidedAccountInCookie(false)
.consentPageExpected(false)
.passwordPageExpected(true)
.speedBumpExpected(false)
.registerPageExpected(false)
.enrollPageExpected(false)
.staySignedInPageExpected(false)
.verifyYourIdentityPageExpected(false)
.howWouldYouLikeToSignInExpected(false)
.build();

// Make sure we get a token
final String token = msalTestApp.acquireToken(username, password, promptHandlerParameters, true);
Assert.assertNotNull(token);

// Launch OS Account page and make sure username shows up in account manager.
getSettingsScreen().launchAccountListPage();
Assert.assertTrue(UiAutomatorUtils.obtainUiObjectWithText(username).exists());
}

@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;
}
}
Loading
Loading