Skip to content

Commit

Permalink
Modify LTW tests to run with MSA accounts (#1959)
Browse files Browse the repository at this point in the history
(Same as title)
Related common PR
AzureAD/microsoft-authentication-library-common-for-android#2243

---------

Co-authored-by: Yixi Lin <[email protected]>
  • Loading branch information
somalaya and yixilin09 authored Nov 27, 2023
1 parent 6bd85f5 commit d8e37a0
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// 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;
Expand All @@ -34,17 +36,38 @@
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;

// LTW has higher priority than CP
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2572280
@LTWTests
@RetryOnFailure
@SupportedBrokers(brokers = {BrokerLTW.class})
@RunWith(Parameterized.class)
public class TestCase2572280 extends AbstractMsalBrokerTest {

private final UserType mUserType;

public TestCase2572280(@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_2572280() throws Throwable {
final String username = mLabAccount.getUsername();
Expand All @@ -56,7 +79,7 @@ public void test_2572280() throws Throwable {
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
Expand Down Expand Up @@ -86,12 +109,14 @@ public void test_2572280() throws Throwable {
}
@Override
public LabQuery getLabQuery() {
return null;
return LabQuery.builder()
.userType(mUserType)
.build();
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// 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;
Expand All @@ -33,16 +35,35 @@
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;

// LTW has higher priority than CP - Case2
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2572283
@LTWTests
@SupportedBrokers(brokers = {BrokerCompanyPortal.class})
@RunWith(Parameterized.class)
public class TestCase2572283 extends AbstractMsalBrokerTest {
private final UserType mUserType;

public TestCase2572283(@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_2572283() throws Throwable {
final String username = mLabAccount.getUsername();
Expand All @@ -54,7 +75,7 @@ public void test_2572283() throws Throwable {
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
Expand Down Expand Up @@ -84,12 +105,14 @@ public void test_2572283() throws Throwable {
}
@Override
public LabQuery getLabQuery() {
return null;
return LabQuery.builder()
.userType(mUserType)
.build();
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// 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;
Expand All @@ -34,15 +36,35 @@
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;

// Authenticator has highest priority - Case1 (LTW, Auth, CP)
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2572294
@LTWTests
@SupportedBrokers(brokers = {BrokerLTW.class})
@RunWith(Parameterized.class)
public class TestCase2572294 extends AbstractMsalBrokerTest {
private final UserType mUserType;

public TestCase2572294(@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_2572294() throws Throwable {
final String username = mLabAccount.getUsername();
Expand All @@ -57,7 +79,7 @@ public void test_2572294() throws Throwable {
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
Expand Down Expand Up @@ -88,12 +110,14 @@ public void test_2572294() throws Throwable {

@Override
public LabQuery getLabQuery() {
return null;
return LabQuery.builder()
.userType(mUserType)
.build();
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// 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;
Expand All @@ -34,15 +36,35 @@
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;

// Authenticator has highest priority - Case2 (LTW, CP, Auth)
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2584409
@LTWTests
@SupportedBrokers(brokers = {BrokerLTW.class})
@RunWith(Parameterized.class)
public class TestCase2584409 extends AbstractMsalBrokerTest {
private final UserType mUserType;

public TestCase2584409(@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_2584409() throws Throwable {
final String username = mLabAccount.getUsername();
Expand All @@ -57,7 +79,7 @@ public void test_2584409() throws Throwable {
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
Expand Down Expand Up @@ -88,12 +110,14 @@ public void test_2584409() throws Throwable {

@Override
public LabQuery getLabQuery() {
return null;
return LabQuery.builder()
.userType(mUserType)
.build();
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// 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;
Expand All @@ -35,16 +37,37 @@
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;

// Authenticator has highest priority - Case3 (Auth, LTW, CP)
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2584410
@LTWTests
@RetryOnFailure
@SupportedBrokers(brokers = {BrokerMicrosoftAuthenticator.class})
@RunWith(Parameterized.class)
public class TestCase2584410 extends AbstractMsalBrokerTest {
private final UserType mUserType;

public TestCase2584410(@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_2584410() throws Throwable {
final String username = mLabAccount.getUsername();
Expand All @@ -59,7 +82,7 @@ public void test_2584410() throws Throwable {
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();
msalTestApp.handleFirstRunBasedOnUserType(mUserType);

final MicrosoftStsPromptHandlerParameters promptHandlerParameters = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
Expand Down Expand Up @@ -90,12 +113,14 @@ public void test_2584410() throws Throwable {

@Override
public LabQuery getLabQuery() {
return null;
return LabQuery.builder()
.userType(mUserType)
.build();
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
return null;
}

@Override
Expand Down
Loading

0 comments on commit d8e37a0

Please sign in to comment.