public async Task GetAccessTokenOrAuthResultForApp_ReturnsAccessTokenOrAuthResultAsync(bool getAuthResult, string authHeaderPrefix) { // Arrange InitializeTokenAcquisitionObjects(); Assert.Equal(0, _msalTestTokenCacheProvider.Count); // Act if (getAuthResult) { TokenAcquisitionOptions tokenAcquisitionOptions = new TokenAcquisitionOptions(); if (authHeaderPrefix == "PoP") { tokenAcquisitionOptions.PoPConfiguration = new Client.AppConfig.PoPAuthenticationConfiguration(new Uri("https://localhost/foo")); } AuthenticationResult authResult = await _tokenAcquisition.GetAuthenticationResultForAppAsync(TestConstants.s_scopeForApp, tokenAcquisitionOptions : tokenAcquisitionOptions).ConfigureAwait(false); // Assert Assert.NotNull(authResult); Assert.NotNull(authResult.AccessToken); Assert.Contains(authHeaderPrefix, authResult.CreateAuthorizationHeader(), System.StringComparison.OrdinalIgnoreCase); Assert.Null(authResult.IdToken); Assert.Null(authResult.Account); } else { string token = await _tokenAcquisition.GetAccessTokenForAppAsync(TestConstants.s_scopeForApp).ConfigureAwait(false); // Assert Assert.NotNull(token); } }
public async Task GetAccessTokenForApp_ReturnsAccessTokenAsync() { // Arrange InitializeTokenAcquisitionObjects(); Assert.Equal(0, _msalTestTokenCacheProvider.Count); // Act string token = await _tokenAcquisition.GetAccessTokenForAppAsync(TestConstants.s_scopeForApp).ConfigureAwait(false); // Assert Assert.NotNull(token); AssertAppTokenInMemoryCache(TestConstants.ConfidentialClientId, 1); }