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); }
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(); }
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(); }
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); }
public IAuthenticator?SelectAuthenticator <T>(T request) where T : IOperationRequest => request.Authenticator ?? _securitySchemeSetRegistry.SelectAuthenticator(typeof(T));