Skip to content

Commit

Permalink
Merge branch 'dev' into melissaahn/Android13SecurityKey
Browse files Browse the repository at this point in the history
  • Loading branch information
melissaahn authored Sep 30, 2024
2 parents 9184ae5 + 70a1913 commit 8f4b5e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.microsoft.identity.client.ui.automation.broker;

import static com.microsoft.identity.client.ui.automation.utils.CommonUtils.FIND_UI_ELEMENT_TIMEOUT;
import static com.microsoft.identity.client.ui.automation.utils.CommonUtils.FIND_UI_ELEMENT_TIMEOUT_LONG;

import androidx.annotation.NonNull;
import androidx.test.platform.app.InstrumentationRegistry;
Expand All @@ -37,8 +38,6 @@

import org.junit.Assert;

import java.util.concurrent.TimeUnit;

/**
* A model for interacting with the Microsoft Authenticator Broker App during UI Test
* when version number of Authenticator app under test is >= "6.2206.3949"
Expand All @@ -47,7 +46,7 @@
public class BrokerAuthenticatorUpdatedVersionImpl extends BrokerMicrosoftAuthenticator {

private static final String TAG = BrokerAuthenticatorUpdatedVersionImpl.class.getSimpleName();
public static boolean shouldUseDeviceSettingsPage = true;
public static boolean shouldUseDeviceSettingsPage = false;

@Override
public void performDeviceRegistration(@NonNull final String username,
Expand Down Expand Up @@ -76,23 +75,13 @@ public void performDeviceRegistration(@NonNull final String username,
);


// after device registration, make sure that we see the unregister btn to confirm successful
// registration

// relaunch device registration page
openDeviceRegistrationPage();

// Click the registered account domain
UiAutomatorUtils.handleButtonClickForObjectWithText(
username.split("@")[1]
);

final UiObject unRegisterBtn = UiAutomatorUtils.obtainUiObjectWithExactText(
"Unregister device", TimeUnit.SECONDS.toMillis(20)
);
// After device registration, make sure that we see device is registered string to
// confirm registration.
final UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject registeredString = device.findObject(new UiSelector().text("Your device is currently registered with:"));
Assert.assertTrue(
"Microsoft Authenticator - Unregister Button appears.",
unRegisterBtn.exists()
"Microsoft Authenticator - Device registered confirmation string appears.",
registeredString.waitForExists(FIND_UI_ELEMENT_TIMEOUT_LONG)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
// THE SOFTWARE.
package com.microsoft.identity.client.ui.automation.device.settings;

import static com.microsoft.identity.client.ui.automation.utils.CommonUtils.FIND_UI_ELEMENT_TIMEOUT_LONG;
import static com.microsoft.identity.client.ui.automation.utils.UiAutomatorUtils.handleButtonClick;
import static com.microsoft.identity.client.ui.automation.utils.UiAutomatorUtils.obtainUiObjectWithExactText;

import androidx.annotation.NonNull;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.uiautomator.UiDevice;
Expand All @@ -40,10 +44,6 @@
import java.util.Calendar;
import java.util.concurrent.TimeUnit;

import static com.microsoft.identity.client.ui.automation.utils.CommonUtils.FIND_UI_ELEMENT_TIMEOUT_LONG;
import static com.microsoft.identity.client.ui.automation.utils.UiAutomatorUtils.handleButtonClick;
import static com.microsoft.identity.client.ui.automation.utils.UiAutomatorUtils.obtainUiObjectWithExactText;

/**
* A model representing the Settings app on a Google device. Please note that this class is
* currently optimized for a Google Pixel 2 device.
Expand Down Expand Up @@ -158,21 +158,22 @@ public void addWorkAccount(@NonNull final ITestBroker broker,

// Find the cert installer and make sure it exists
UiObject certInstaller = device.findObject(new UiSelector().packageName("com.android.certinstaller"));
Assert.assertTrue(
"Cert Installer appears while adding work account",
certInstaller.waitForExists(FIND_UI_ELEMENT_TIMEOUT_LONG)
);
if (certInstaller.waitForExists(FIND_UI_ELEMENT_TIMEOUT_LONG)) {

// Confirm install cert
UiAutomatorUtils.handleButtonClick("android:id/button1");
// Confirm install cert
UiAutomatorUtils.handleButtonClick("android:id/button1");

// Confirm cert name (API 30+ only)
if (android.os.Build.VERSION.SDK_INT >= 30) {
UiAutomatorUtils.handleButtonClickSafely("android:id/button1");
// Confirm cert name (API 30+ only)
if (android.os.Build.VERSION.SDK_INT >= 30) {
UiAutomatorUtils.handleButtonClickSafely("android:id/button1");
}
// Make sure account appears in Join Activity afterwards
broker.confirmJoinInJoinActivity(username);
} else {
// Click OK button
UiAutomatorUtils.handleButtonClickForObjectWithExactText("OK");
}

// Make sure account appears in Join Activity afterwards
broker.confirmJoinInJoinActivity(username);
} catch (final UiObjectNotFoundException e) {
throw new AssertionError(e);
}
Expand Down

0 comments on commit 8f4b5e0

Please sign in to comment.