Пример #1
0
        public void IsAuthenticationDisabledTest()
        {
            var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>();
            var sut = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory.Object);

            Assert.False(sut.IsAuthenticationDisabledAsync(CancellationToken.None).GetAwaiter().GetResult());
        }
Пример #2
0
 public void CannotCreateCredentialsFactoryWithoutTokenProviderFactory()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         _ = new ManagedIdentityServiceClientCredentialsFactory(TestAppId, tokenProviderFactory: null);
     });
 }
Пример #3
0
        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());
        }
Пример #4
0
 public void CannotCreateCredentialsFactoryWithoutAppId(string appId)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var tokenProviderFactory = new Mock <IJwtTokenProviderFactory>();
         _ = new ManagedIdentityServiceClientCredentialsFactory(appId, tokenProviderFactory.Object);
     });
 }
Пример #5
0
        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);
        }
Пример #6
0
        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);
            });
        }
Пример #7
0
        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);
            }
        }