Beispiel #1
0
        public void VstsAadRefreshCredentialsTest()
        {
            TargetUri             targetUri         = DefaultTargetUri;
            TargetUri             invalidUri        = InvalidTargetUri;
            VstsAadAuthentication aadAuthentication = GetVstsAadAuthentication("aad-refresh");

            aadAuthentication.AdaRefreshTokenStore.WriteToken(targetUri, DefaultAzureRefreshToken);

            Credential personalAccessToken;

            Assert.IsFalse(aadAuthentication.PersonalAccessTokenStore.ReadCredentials(targetUri, out personalAccessToken), "Personal Access Token unexpectedly found in store.");

            Assert.IsTrue(Task.Run(async() => { return(await aadAuthentication.RefreshCredentials(targetUri, false)); }).Result, "Credentials refresh failed unexpectedly.");
            Assert.IsFalse(Task.Run(async() => { return(await aadAuthentication.RefreshCredentials(invalidUri, false)); }).Result, "Credentials refresh succeeded unexpectedly.");

            Assert.IsTrue(aadAuthentication.PersonalAccessTokenStore.ReadCredentials(targetUri, out personalAccessToken), "Personal Access Token not found in store as expected.");
        }