Commit 7dd7f7a4 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Fix failing Fido2CredentialRequestTest tests

The tests weren't destroying the WindowAndroid they created, the fix is
trivial.

I also replaced the deprecated TestUtils#runOnUiThreadBlocking since I
was touching this file anyways.

Bug: 1130845
Change-Id: I4b570e31dc6161e5df45d93160f23c92d5c3bfd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427205
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarNina Satragno <nsatragno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809947}
parent bc1abeb2
...@@ -26,7 +26,6 @@ import org.mockito.MockitoAnnotations; ...@@ -26,7 +26,6 @@ import org.mockito.MockitoAnnotations;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.PackageUtils; import org.chromium.base.PackageUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter; import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate; import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterProvider; import org.chromium.base.test.params.ParameterProvider;
...@@ -72,7 +71,6 @@ import java.util.List; ...@@ -72,7 +71,6 @@ import java.util.List;
ContentSwitches.HOST_RESOLVER_RULES + "=MAP * 127.0.0.1", ContentSwitches.HOST_RESOLVER_RULES + "=MAP * 127.0.0.1",
"enable-experimental-web-platform-features", "enable-features=WebAuthentication", "enable-experimental-web-platform-features", "enable-features=WebAuthentication",
"ignore-certificate-errors"}) "ignore-certificate-errors"})
@DisabledTest(message = "https://crbug.com/1130845")
public class Fido2CredentialRequestTest { public class Fido2CredentialRequestTest {
@Rule @Rule
public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
...@@ -397,14 +395,19 @@ public class Fido2CredentialRequestTest { ...@@ -397,14 +395,19 @@ public class Fido2CredentialRequestTest {
mAuthenticatorImpl = AuthenticatorImpl.create(0, mFrameHost); mAuthenticatorImpl = AuthenticatorImpl.create(0, mFrameHost);
mCreationOptions = Fido2ApiTestHelper.createDefaultMakeCredentialOptions(); mCreationOptions = Fido2ApiTestHelper.createDefaultMakeCredentialOptions();
mRequestOptions = Fido2ApiTestHelper.createDefaultGetAssertionOptions(); mRequestOptions = Fido2ApiTestHelper.createDefaultGetAssertionOptions();
ThreadUtils.runOnUiThreadBlocking(() TestThreadUtils.runOnUiThreadBlocking(
-> mWindowAndroid = new MockActivityWindowAndroid( ()
mActivityTestRule.getActivity())); -> mWindowAndroid =
new MockActivityWindowAndroid(mActivityTestRule.getActivity()));
mStartTimeMs = SystemClock.elapsedRealtime(); mStartTimeMs = SystemClock.elapsedRealtime();
} }
@After @After
public void tearDown() {} public void tearDown() {
TestThreadUtils.runOnUiThreadBlocking(() -> {
if (mWindowAndroid != null) mWindowAndroid.destroy();
});
}
/** /**
* Used to enable early exit of tests on bots that don't support GmsCore v16.1+ * Used to enable early exit of tests on bots that don't support GmsCore v16.1+
...@@ -433,7 +436,7 @@ public class Fido2CredentialRequestTest { ...@@ -433,7 +436,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_success() { public void testMakeCredential_success() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -447,7 +450,7 @@ public class Fido2CredentialRequestTest { ...@@ -447,7 +450,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_unsuccessfulAttemptToShowCancelableIntent() { public void testMakeCredential_unsuccessfulAttemptToShowCancelableIntent() {
mWindowAndroid.setCancelableIntentSuccess(false); mWindowAndroid.setCancelableIntentSuccess(false);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -462,7 +465,7 @@ public class Fido2CredentialRequestTest { ...@@ -462,7 +465,7 @@ public class Fido2CredentialRequestTest {
public void testMakeCredential_missingExtra() { public void testMakeCredential_missingExtra() {
// An intent missing FIDO2_KEY_RESPONSE_EXTRA. // An intent missing FIDO2_KEY_RESPONSE_EXTRA.
mWindowAndroid.setResponseIntent(new Intent()); mWindowAndroid.setResponseIntent(new Intent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -476,7 +479,7 @@ public class Fido2CredentialRequestTest { ...@@ -476,7 +479,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_nullIntent() { public void testMakeCredential_nullIntent() {
// Don't set an intent to be returned at all. // Don't set an intent to be returned at all.
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -490,7 +493,7 @@ public class Fido2CredentialRequestTest { ...@@ -490,7 +493,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_resultCanceled() { public void testMakeCredential_resultCanceled() {
mWindowAndroid.setResultCode(Activity.RESULT_CANCELED); mWindowAndroid.setResultCode(Activity.RESULT_CANCELED);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -505,7 +508,7 @@ public class Fido2CredentialRequestTest { ...@@ -505,7 +508,7 @@ public class Fido2CredentialRequestTest {
public void testMakeCredential_resultUnknown() { public void testMakeCredential_resultUnknown() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
mWindowAndroid.setResultCode(Activity.RESULT_FIRST_USER); mWindowAndroid.setResultCode(Activity.RESULT_FIRST_USER);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
...@@ -521,7 +524,7 @@ public class Fido2CredentialRequestTest { ...@@ -521,7 +524,7 @@ public class Fido2CredentialRequestTest {
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
customOptions.relyingParty.icon = null; customOptions.relyingParty.icon = null;
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback);
...@@ -537,7 +540,7 @@ public class Fido2CredentialRequestTest { ...@@ -537,7 +540,7 @@ public class Fido2CredentialRequestTest {
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
customOptions.user.icon = null; customOptions.user.icon = null;
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback);
...@@ -589,7 +592,7 @@ public class Fido2CredentialRequestTest { ...@@ -589,7 +592,7 @@ public class Fido2CredentialRequestTest {
customOptions.publicKeyParameters[0], parameters}; customOptions.publicKeyParameters[0], parameters};
customOptions.publicKeyParameters = multiParams; customOptions.publicKeyParameters = multiParams;
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(customOptions, mFrameHost, mOrigin, mCallback);
...@@ -603,7 +606,7 @@ public class Fido2CredentialRequestTest { ...@@ -603,7 +606,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_noExcludeCredentials() { public void testMakeCredential_noExcludeCredentials() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
...@@ -681,7 +684,7 @@ public class Fido2CredentialRequestTest { ...@@ -681,7 +684,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testGetAssertionWithoutUvmRequested_success() { public void testGetAssertionWithoutUvmRequested_success() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -694,7 +697,7 @@ public class Fido2CredentialRequestTest { ...@@ -694,7 +697,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testGetAssertionWithUvmRequestedWithoutUvmResponded_success() { public void testGetAssertionWithUvmRequestedWithoutUvmResponded_success() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequestOptions.userVerificationMethods = true; mRequestOptions.userVerificationMethods = true;
...@@ -710,7 +713,7 @@ public class Fido2CredentialRequestTest { ...@@ -710,7 +713,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertionWithUvmRequestedWithUvmResponded_success() { public void testGetAssertionWithUvmRequestedWithUvmResponded_success() {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createSuccessfulGetAssertionIntentWithUvm()); Fido2ApiTestHelper.createSuccessfulGetAssertionIntentWithUvm());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequestOptions.userVerificationMethods = true; mRequestOptions.userVerificationMethods = true;
...@@ -725,7 +728,7 @@ public class Fido2CredentialRequestTest { ...@@ -725,7 +728,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testGetAssertion_unsuccessfulAttemptToShowCancelableIntent() { public void testGetAssertion_unsuccessfulAttemptToShowCancelableIntent() {
mWindowAndroid.setCancelableIntentSuccess(false); mWindowAndroid.setCancelableIntentSuccess(false);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -740,7 +743,7 @@ public class Fido2CredentialRequestTest { ...@@ -740,7 +743,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertion_missingExtra() { public void testGetAssertion_missingExtra() {
// An intent missing FIDO2_KEY_RESPONSE_EXTRA. // An intent missing FIDO2_KEY_RESPONSE_EXTRA.
mWindowAndroid.setResponseIntent(new Intent()); mWindowAndroid.setResponseIntent(new Intent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -754,7 +757,7 @@ public class Fido2CredentialRequestTest { ...@@ -754,7 +757,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testGetAssertion_nullIntent() { public void testGetAssertion_nullIntent() {
// Don't set an intent to be returned at all. // Don't set an intent to be returned at all.
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -768,7 +771,7 @@ public class Fido2CredentialRequestTest { ...@@ -768,7 +771,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testGetAssertion_resultCanceled() { public void testGetAssertion_resultCanceled() {
mWindowAndroid.setResultCode(Activity.RESULT_CANCELED); mWindowAndroid.setResultCode(Activity.RESULT_CANCELED);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -783,7 +786,7 @@ public class Fido2CredentialRequestTest { ...@@ -783,7 +786,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertion_resultUnknown() { public void testGetAssertion_resultUnknown() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent());
mWindowAndroid.setResultCode(Activity.RESULT_FIRST_USER); mWindowAndroid.setResultCode(Activity.RESULT_FIRST_USER);
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -798,7 +801,7 @@ public class Fido2CredentialRequestTest { ...@@ -798,7 +801,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertion_unknownErrorCredentialNotRecognized() { public void testGetAssertion_unknownErrorCredentialNotRecognized() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent( mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent(
ErrorCode.UNKNOWN_ERR, "Low level error 0x6a80")); ErrorCode.UNKNOWN_ERR, "Low level error 0x6a80"));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -814,7 +817,7 @@ public class Fido2CredentialRequestTest { ...@@ -814,7 +817,7 @@ public class Fido2CredentialRequestTest {
PublicKeyCredentialRequestOptions customOptions = mRequestOptions; PublicKeyCredentialRequestOptions customOptions = mRequestOptions;
customOptions.appid = "www.example.com"; customOptions.appid = "www.example.com";
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulGetAssertionIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
...@@ -896,7 +899,7 @@ public class Fido2CredentialRequestTest { ...@@ -896,7 +899,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_attestationNone() { public void testMakeCredential_attestationNone() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
...@@ -912,7 +915,7 @@ public class Fido2CredentialRequestTest { ...@@ -912,7 +915,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_attestationIndirect() { public void testMakeCredential_attestationIndirect() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
...@@ -929,7 +932,7 @@ public class Fido2CredentialRequestTest { ...@@ -929,7 +932,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_attestationDirect() { public void testMakeCredential_attestationDirect() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
...@@ -945,7 +948,7 @@ public class Fido2CredentialRequestTest { ...@@ -945,7 +948,7 @@ public class Fido2CredentialRequestTest {
@SmallTest @SmallTest
public void testMakeCredential_attestationEnterprise() { public void testMakeCredential_attestationEnterprise() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent()); mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createSuccessfulMakeCredentialIntent());
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
PublicKeyCredentialCreationOptions customOptions = mCreationOptions; PublicKeyCredentialCreationOptions customOptions = mCreationOptions;
...@@ -964,7 +967,7 @@ public class Fido2CredentialRequestTest { ...@@ -964,7 +967,7 @@ public class Fido2CredentialRequestTest {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.INVALID_STATE_ERR, Fido2ApiTestHelper.createErrorIntent(ErrorCode.INVALID_STATE_ERR,
"One of the excluded credentials exists on the local device")); "One of the excluded credentials exists on the local device"));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -982,7 +985,7 @@ public class Fido2CredentialRequestTest { ...@@ -982,7 +985,7 @@ public class Fido2CredentialRequestTest {
// Passes conversion and gets rejected by GmsCore // Passes conversion and gets rejected by GmsCore
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent( mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent(
ErrorCode.NOT_ALLOWED_ERR, "Authentication request must have non-empty allowList")); ErrorCode.NOT_ALLOWED_ERR, "Authentication request must have non-empty allowList"));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1002,7 +1005,7 @@ public class Fido2CredentialRequestTest { ...@@ -1002,7 +1005,7 @@ public class Fido2CredentialRequestTest {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.NOT_ALLOWED_ERR, Fido2ApiTestHelper.createErrorIntent(ErrorCode.NOT_ALLOWED_ERR,
"Request doesn't have a valid list of allowed credentials.")); "Request doesn't have a valid list of allowed credentials."));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1017,7 +1020,7 @@ public class Fido2CredentialRequestTest { ...@@ -1017,7 +1020,7 @@ public class Fido2CredentialRequestTest {
public void testMakeCredential_constraintErrorNoScreenlock() { public void testMakeCredential_constraintErrorNoScreenlock() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent( mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent(
ErrorCode.CONSTRAINT_ERR, "The device is not secured with any screen lock")); ErrorCode.CONSTRAINT_ERR, "The device is not secured with any screen lock"));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1031,7 +1034,7 @@ public class Fido2CredentialRequestTest { ...@@ -1031,7 +1034,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertion_constraintErrorNoScreenlock() { public void testGetAssertion_constraintErrorNoScreenlock() {
mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent( mWindowAndroid.setResponseIntent(Fido2ApiTestHelper.createErrorIntent(
ErrorCode.CONSTRAINT_ERR, "The device is not secured with any screen lock")); ErrorCode.CONSTRAINT_ERR, "The device is not secured with any screen lock"));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1047,7 +1050,7 @@ public class Fido2CredentialRequestTest { ...@@ -1047,7 +1050,7 @@ public class Fido2CredentialRequestTest {
String errorCodeName, String errorMsg, Integer status) { String errorCodeName, String errorMsg, Integer status) {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), errorMsg)); Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), errorMsg));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1061,7 +1064,7 @@ public class Fido2CredentialRequestTest { ...@@ -1061,7 +1064,7 @@ public class Fido2CredentialRequestTest {
public void testGetAssertion_with_param(String errorCodeName, String errorMsg, Integer status) { public void testGetAssertion_with_param(String errorCodeName, String errorMsg, Integer status) {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), errorMsg)); Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), errorMsg));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1076,7 +1079,7 @@ public class Fido2CredentialRequestTest { ...@@ -1076,7 +1079,7 @@ public class Fido2CredentialRequestTest {
String errorCodeName, String errorMsg, Integer status) { String errorCodeName, String errorMsg, Integer status) {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), null)); Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), null));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback); mRequest.handleMakeCredentialRequest(mCreationOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
...@@ -1091,7 +1094,7 @@ public class Fido2CredentialRequestTest { ...@@ -1091,7 +1094,7 @@ public class Fido2CredentialRequestTest {
String errorCodeName, String errorMsg, Integer status) { String errorCodeName, String errorMsg, Integer status) {
mWindowAndroid.setResponseIntent( mWindowAndroid.setResponseIntent(
Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), null)); Fido2ApiTestHelper.createErrorIntent(ErrorCode.valueOf(errorCodeName), null));
ThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> mRequest.setActivityWindowForTesting(mWindowAndroid)); () -> mRequest.setActivityWindowForTesting(mWindowAndroid));
mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback); mRequest.handleGetAssertionRequest(mRequestOptions, mFrameHost, mOrigin, mCallback);
mCallback.blockUntilCalled(); mCallback.blockUntilCalled();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment