Esempio n. 1
0
        public void SelectAuthenticator_TwoSchemesBothConfigured_ReturnsFirstAuthenticator()
        {
            // Arrange

            var authenticators = new TestAuthenticators {
                Auth1 = new TestAuth1(), Auth2 = new TestAuth2()
            };

            var registry = new SecuritySchemeSetRegistry <TestAuthenticators>(authenticators);

            // Act

            var result = registry.SelectAuthenticator(typeof(TwoSchemesRequest));

            // Assert

            result.Should().BeSameAs(authenticators.Auth1);
        }
Esempio n. 2
0
        public void SelectAuthenticator_SingleSchemeNotConfigured_ReturnsNull()
        {
            // Arrange

            var authenticators = new TestAuthenticators {
                Auth1 = null, Auth2 = new TestAuth2()
            };

            var registry = new SecuritySchemeSetRegistry <TestAuthenticators>(authenticators);

            // Act

            var result = registry.SelectAuthenticator(typeof(OneSchemeRequest));

            // Assert

            result.Should().BeNull();
        }
Esempio n. 3
0
        public void SelectAuthenticator_NoSchemes_ReturnsNull()
        {
            // Arrange

            var authenticators = new TestAuthenticators {
                Auth1 = new TestAuth1(), Auth2 = new TestAuth2()
            };

            var registry = new SecuritySchemeSetRegistry <TestAuthenticators>(authenticators);

            // Act

            var result = registry.SelectAuthenticator(typeof(NoSchemesRequest));

            // Assert

            result.Should().BeNull();
        }
Esempio n. 4
0
        public void SelectAuthenticator_JoinedSchemesBothConfigured_ReturnsMultiAuthenticator()
        {
            // Arrange

            var authenticators = new TestAuthenticators {
                Auth1 = new TestAuth1(), Auth2 = new TestAuth2()
            };

            var registry = new SecuritySchemeSetRegistry <TestAuthenticators>(authenticators);

            // Act

            var result = registry.SelectAuthenticator(typeof(JoinedSchemesRequest));

            // Assert

            result.Should().BeOfType <MultiAuthenticator>().Which
            .Authenticators.Should().BeEquivalentTo(authenticators.Auth1, authenticators.Auth2);
        }
Esempio n. 5
0
 public IAuthenticator?SelectAuthenticator <T>(T request)
     where T : IOperationRequest =>
 request.Authenticator ?? _securitySchemeSetRegistry.SelectAuthenticator(typeof(T));