public void IsAuthenticationDisabledTest() { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); var sut = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object); Assert.False(sut.IsAuthenticationDisabledAsync(CancellationToken.None).GetAwaiter().GetResult()); }
public void CannotCreateCredentialsFactoryWithoutTokenProviderFactory() { Assert.Throws <ArgumentNullException>(() => { _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory: null); }); }
public void IsValidAppIdTest() { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); var sut = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object); Assert.True(sut.IsValidAppIdAsync(TestAppId, CancellationToken.None).GetAwaiter().GetResult()); Assert.False(sut.IsValidAppIdAsync("InvalidAppId", CancellationToken.None).GetAwaiter().GetResult()); }
public void CannotCreateCredentialsFactoryWithoutAppId(string appId) { Assert.Throws <ArgumentNullException>(() => { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); _ = new ManagedIdentityServiceClientCredentialsFactory(appId, tokenProviderFactory.Object); }); }
public void CanCreateCredentials() { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); var sut = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object); var credentials = sut.CreateCredentialsAsync( TestAppId, TestAudience, "https://login.microsoftonline.com", true, CancellationToken.None); Assert.NotNull(credentials); }
public void CannotCreateCredentialsWithInvalidAppId() { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); var sut = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object); Assert.Throws <InvalidOperationException>(() => { _ = sut.CreateCredentialsAsync( "InvalidAppId", TestAudience, "https://login.microsoftonline.com", true, CancellationToken.None); }); }
public void ConstructorTests() { var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>(); _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object); using (var customHttpClient = new HttpClient()) { _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object, customHttpClient); var logger = new Mock <ILogger>(); _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object, null, logger.Object); _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object, customHttpClient, logger.Object); } }