Skip to content

Commit c76ba03

Browse files
authored
Merge branch 'dev' into revert-2651-revert-2587-gradleVersionChange2
2 parents b37cfb0 + e443777 commit c76ba03

12 files changed

Lines changed: 89 additions & 48 deletions

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/IOAuth2LoginComponentHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ public interface IOAuth2LoginComponentHandler {
3838
/**
3939
* Enters the supplied password in the password field of a login page.
4040
*
41-
* @param password the password of the user
41+
* @param password the password of the user
42+
* @param isMsaAccount whether or not using msa account
4243
*/
43-
void handlePasswordField(final String password);
44+
void handlePasswordField(final String password, final boolean isMsaAccount);
4445

4546
/**
4647
* Clicks the back button on a login page.

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/b2c/B2CIdLabLocalLoginComponentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void handleEmailField(@NonNull final String username) {
4545
}
4646

4747
@Override
48-
public void handlePasswordField(@NonNull final String password) {
48+
public void handlePasswordField(@NonNull final String password, final boolean isMsaAccount) {
4949
Logger.i(TAG, "Handle B2C IdLab Local Login Password UI..");
5050
UiAutomatorUtils.handleInput("password", password);
5151
handleNextButton();

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/b2c/FacebookLoginComponentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void handleEmailField(@NonNull final String username) {
4949
}
5050

5151
@Override
52-
public void handlePasswordField(@NonNull final String password) {
52+
public void handlePasswordField(@NonNull final String password, final boolean isMsaAccount) {
5353
Logger.i(TAG, "Handle Facebook Login Password UI..");
5454
UiAutomatorUtils.handleInput("m_login_password", password);
5555
handleNextButton();

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/b2c/GoogleLoginComponentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void handleEmailField(@NonNull final String username) {
5555
}
5656

5757
@Override
58-
public void handlePasswordField(@NonNull final String password) {
58+
public void handlePasswordField(@NonNull final String password, final boolean isMsaAccount) {
5959
Logger.i(TAG, "Handle Google Login Password UI..");
6060
UiAutomatorUtils.handleInput("password", password);
6161
final UiObject passwordBox = UiAutomatorUtils.obtainUiObjectWithResourceId("password");

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/b2c/IdLabB2cSisoPolicyPromptHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void handlePrompt(@NonNull final String username, @NonNull final String p
6666
}
6767

6868
if (!parameters.isSessionExpected()) {
69-
loginComponentHandler.handlePasswordField(password);
69+
loginComponentHandler.handlePasswordField(password, false);
7070

7171
if (loginComponentHandler instanceof GoogleLoginComponentHandler &&
7272
b2CProvider == B2CProviderWrapper.Google){

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/microsoftsts/AadLoginComponentHandler.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import androidx.test.platform.app.InstrumentationRegistry;
2727
import androidx.test.uiautomator.UiDevice;
2828
import androidx.test.uiautomator.UiObject;
29-
import androidx.test.uiautomator.UiObject2;
3029
import androidx.test.uiautomator.UiObjectNotFoundException;
3130
import androidx.test.uiautomator.UiSelector;
3231

@@ -42,7 +41,6 @@
4241

4342
import android.widget.Button;
4443

45-
import java.util.List;
4644
import java.util.concurrent.TimeUnit;
4745

4846
/**
@@ -80,8 +78,26 @@ public void handleEmailField(@NonNull final String username) {
8078
}
8179

8280
@Override
83-
public void handlePasswordField(@NonNull final String password) {
81+
public void handlePasswordField(@NonNull final String password, final boolean isMsaAccount) {
8482
Logger.i(TAG, "Handle Aad Login Password UI..");
83+
84+
// We need to temporarily handle both possible flows for msa accounts.
85+
// 1. If the user is using an MSA account, we may see a screen prompting MFA or OTP, with an option that
86+
// says "Other ways to sign in"
87+
// 2. No OTP or MFA, just prompted for password right away.
88+
if (isMsaAccount) {
89+
final UiObject otherWays = UiAutomatorUtils.obtainUiObjectWithExactText("Other ways to sign in", CommonUtils.FIND_UI_ELEMENT_TIMEOUT_SHORT);
90+
if (otherWays.exists()) {
91+
try {
92+
otherWays.click();
93+
94+
UiAutomatorUtils.handleButtonClickForObjectWithExactText("Use your password");
95+
} catch (final UiObjectNotFoundException e) {
96+
throw new AssertionError(e);
97+
}
98+
}
99+
}
100+
85101
UiAutomatorUtils.obtainUiObjectWithText("password", mFindLoginUiElementTimeout);
86102
try {
87103
UiAutomatorUtils.handleInputByClass("android.widget.EditText", password, mFindLoginUiElementTimeout);

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/microsoftsts/AdfsLoginComponentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void handleEmailField(@NonNull final String username) {
4848
}
4949

5050
@Override
51-
public void handlePasswordField(@NonNull final String password) {
51+
public void handlePasswordField(@NonNull final String password, final boolean isMsaAccount) {
5252
Logger.i(TAG, "Handle Adfs Login Password UI..");
5353
try {
5454
UiAutomatorUtils.handleInput("passwordInput", password, CommonUtils.FIND_UI_ELEMENT_TIMEOUT_SHORT);

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/microsoftsts/MicrosoftStsPromptHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public void handlePrompt(@NonNull final String username, @NonNull final String p
6666
final IMicrosoftStsLoginComponentHandler aadLoginComponentHandler =
6767
(IMicrosoftStsLoginComponentHandler) loginComponentHandler;
6868

69+
final Boolean isMsaAccount = isMsaAccount(username);
70+
6971
// if login hint was not provided, then we need to handle either account picker or email
7072
// field. If it was provided, then we expect to go straight to password field.
7173
if (!loginHintProvided) {
@@ -89,7 +91,7 @@ public void handlePrompt(@NonNull final String username, @NonNull final String p
8991
}
9092

9193
if (parameters.isPasswordPageExpected() || parameters.getPrompt() == PromptParameter.LOGIN || !parameters.isSessionExpected()) {
92-
loginComponentHandler.handlePasswordField(password);
94+
loginComponentHandler.handlePasswordField(password, isMsaAccount);
9395
}
9496

9597
if (parameters.isVerifyYourIdentityPageExpected()) {
@@ -142,10 +144,16 @@ public void handlePrompt(@NonNull final String username, @NonNull final String p
142144

143145
if (parameters.isSecondPasswordPageExpected()) {
144146
try {
145-
loginComponentHandler.handlePasswordField(password);
147+
loginComponentHandler.handlePasswordField(password, isMsaAccount);
146148
} catch (AssertionError e) {
147149
// Let's not throw an error if we fail on the second password field, sometimes seems to not show up in tests that use it.
148150
}
149151
}
150152
}
153+
154+
private Boolean isMsaAccount(@NonNull final String username) {
155+
// We'll probably need to update this in the future, if additional MSA accounts get
156+
// added to lab that don't have outlook domain
157+
return username.contains("outlook.com");
158+
}
151159
}

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/interaction/microsoftsts/TlsPromptHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package com.microsoft.identity.client.ui.automation.interaction.microsoftsts;
2424

2525
import android.text.TextUtils;
26-
import android.widget.ImageButton;
2726

2827
import androidx.annotation.NonNull;
2928
import androidx.test.platform.app.InstrumentationRegistry;
@@ -42,8 +41,6 @@
4241

4342
import java.util.concurrent.TimeUnit;
4443

45-
import static com.microsoft.identity.client.ui.automation.utils.CommonUtils.FIND_UI_ELEMENT_TIMEOUT;
46-
4744
/**
4845
* A Prompt Handler for TLS login flows.
4946
*/
@@ -109,7 +106,7 @@ public void handlePrompt(@NonNull final String username, @NonNull final String p
109106
}
110107

111108
if (parameters.isPasswordPageExpected() || parameters.getPrompt() == PromptParameter.LOGIN || !parameters.isSessionExpected()) {
112-
loginComponentHandler.handlePasswordField(password);
109+
loginComponentHandler.handlePasswordField(password, false);
113110
}
114111
// installing certificate.
115112
UiAutomatorUtils.handleButtonClick("android:id/button1");

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/rules/PowerLiftIncidentRule.java

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.text.TextUtils;
44

5+
import androidx.annotation.Nullable;
6+
57
import com.microsoft.identity.client.ui.automation.powerlift.IPowerLiftIntegratedApp;
68
import com.microsoft.identity.client.ui.automation.logging.Logger;
79
import com.microsoft.identity.client.ui.automation.powerlift.ThrowableWithPowerLiftIncident;
@@ -32,33 +34,41 @@ public void evaluate() throws Throwable {
3234
try {
3335
base.evaluate();
3436
} catch (final Throwable originalThrowable) {
35-
String powerLiftIncidentDetails = null;
36-
try {
37-
Logger.e(
38-
TAG,
39-
"Encountered error during test....creating PowerLift incident.",
40-
originalThrowable
41-
);
42-
powerLiftIncidentDetails = powerLiftIntegratedApp.createPowerLiftIncident();
43-
} catch (final Throwable powerLiftError) {
44-
Logger.e(
45-
TAG,
46-
"Oops...something went wrong...unable to create PowerLift incident.",
47-
powerLiftError
48-
);
49-
}
50-
if (TextUtils.isEmpty(powerLiftIncidentDetails)) {
51-
throw originalThrowable;
52-
} else {
53-
assert powerLiftIncidentDetails != null;
54-
throw new ThrowableWithPowerLiftIncident(
55-
powerLiftIntegratedApp,
56-
powerLiftIncidentDetails,
57-
originalThrowable
58-
);
59-
}
37+
attemptPowerLiftIncident(originalThrowable, powerLiftIntegratedApp);
6038
}
6139
}
6240
};
6341
}
42+
43+
public static void attemptPowerLiftIncident(final Throwable originalThrowable, @Nullable final IPowerLiftIntegratedApp powerLiftIntegratedApp) throws Throwable {
44+
if (powerLiftIntegratedApp == null) {
45+
throw originalThrowable;
46+
}
47+
48+
String powerLiftIncidentDetails = null;
49+
try {
50+
Logger.e(
51+
TAG,
52+
"Encountered error during test....creating PowerLift incident.",
53+
originalThrowable
54+
);
55+
powerLiftIncidentDetails = powerLiftIntegratedApp.createPowerLiftIncident();
56+
} catch (final Throwable powerLiftError) {
57+
Logger.e(
58+
TAG,
59+
"Oops...something went wrong...unable to create PowerLift incident.",
60+
powerLiftError
61+
);
62+
}
63+
if (TextUtils.isEmpty(powerLiftIncidentDetails)) {
64+
throw originalThrowable;
65+
} else {
66+
assert powerLiftIncidentDetails != null;
67+
throw new ThrowableWithPowerLiftIncident(
68+
powerLiftIntegratedApp,
69+
powerLiftIncidentDetails,
70+
originalThrowable
71+
);
72+
}
73+
}
6474
}

0 commit comments

Comments
 (0)