예제 #1
0
        [Timeout(1 * 60 * 1000)] // 1 min timeout
        public async Task DeviceCodeFlowTestAsync()
        {
            LabResponse labResponse = LabUserHelper.GetDefaultUser();

            Trace.WriteLine("Calling AcquireTokenWithDeviceCodeAsync");
            PublicClientApplication pca = new PublicClientApplication(labResponse.AppId);
            var result = await pca.AcquireTokenWithDeviceCodeAsync(Scopes, deviceCodeResult =>
            {
                RunAutomatedDeviceCodeFlow(deviceCodeResult, labResponse.User);

                return(Task.FromResult(0));
            }).ConfigureAwait(false);

            Trace.WriteLine("Running asserts");

            Assert.IsNotNull(result);
            Assert.IsTrue(!string.IsNullOrEmpty(result.AccessToken));
        }
        public async Task AcquireTokenWithFederatedUsernamePasswordAsync()
        {
            var user = LabUserHelper.GetDefaultUser().User;

            SecureString securePassword = new NetworkCredential("", LabUserHelper.GetUserPassword(user)).SecurePassword;

            PublicClientApplication msalPublicClient = new PublicClientApplication(ClientId, Authority);
            AuthenticationResult    authResult       = await msalPublicClient.AcquireTokenByUsernamePasswordAsync(Scopes, user.Upn, securePassword).ConfigureAwait(false);

            Assert.IsNotNull(authResult);
            Assert.IsNotNull(authResult.AccessToken);
            Assert.IsNotNull(authResult.IdToken);
            Assert.AreEqual(user.Upn, authResult.Account.Username);
            // If test fails with "user needs to consent to the application, do an interactive request" error,
            // Do the following:
            // 1) Add in code to pull the user's password before creating the SecureString, and put a breakpoint there.
            // string password = ((LabUser)user).GetPassword();
            // 2) Using the MSAL Desktop app, make sure the ClientId matches the one used in integration testing.
            // 3) Do the interactive sign-in with the MSAL Desktop app with the username and password from step 1.
            // 4) After successful log-in, remove the password line you added in with step 1, and run the integration test again.
        }
        public void PromptBehavior_Consent_SelectAccount()
        {
            var labData = LabUserHelper.GetDefaultUser();

            // 1. Acquire token with uiBehavior set to consent
            _msalMobileTestHelper.AcquireTokenInteractiveTestHelper(
                xamarinController,
                labData,
                CoreUiTestConstants.UIBehaviorConsent);

            // 2. Switch ui behavior to "select account"
            _msalMobileTestHelper.SetUiBehavior(xamarinController, CoreUiTestConstants.UIBehaviorSelectAccount);

            // 3. Hit Acquire Token directly since we are not changing any other setting
            xamarinController.Tap(CoreUiTestConstants.AcquireTokenID);

            // 4. The web UI should display all users, so click on the current user
            xamarinController.Tap(labData.User.Upn, XamarinSelector.ByHtmlValue);

            // 5. Validate token again
            _msalMobileTestHelper.CoreMobileTestHelper.VerifyResult(xamarinController);
        }
예제 #4
0
        public async Task ROPC_AAD_Async()
        {
            var labResponse = LabUserHelper.GetDefaultUser();

            await RunHappyPathTestAsync(labResponse).ConfigureAwait(false);
        }
 public void AcquireTokenSilentTest()
 {
     _mobileTestHelper.AcquireTokenSilentTestHelper(xamarinController, LabUserHelper.GetDefaultUser());
 }
        public void PromptBehaviorConsentSelectAccount()
        {
            var labResponse = LabUserHelper.GetDefaultUser();

            _mobileTestHelper.PromptBehaviorTestHelperWithConsent(xamarinController, labResponse);
        }
 public void AcquireTokenTest()
 {
     _msalMobileTestHelper.AcquireTokenInteractiveTestHelper(xamarinController, LabUserHelper.GetDefaultUser());
 }