Class MockAuthenticationProvider<T,I,S>
java.lang.Object
io.micronaut.security.testutils.authprovider.MockAuthenticationProvider<T,I,S>
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,ReactiveAuthenticationProvider<T,
I, S>
public class MockAuthenticationProvider<T,I,S>
extends Object
implements ReactiveAuthenticationProvider<T,I,S>
Utility class to mock authentication scenarios.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionMockAuthenticationProvider
(List<SuccessAuthenticationScenario> successAuthenticationScenarioList) MockAuthenticationProvider
(List<SuccessAuthenticationScenario> successAuthenticationScenarioList, List<FailedAuthenticationScenario> failedAuthenticationScenarioList) -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<AuthenticationResponse>
authenticate
(T requestContext, AuthenticationRequest<I, S> authenticationRequest) Authenticates a user with the given request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
Methods inherited from interface io.micronaut.security.authentication.provider.ReactiveAuthenticationProvider
authenticate
-
Constructor Details
-
MockAuthenticationProvider
public MockAuthenticationProvider(List<SuccessAuthenticationScenario> successAuthenticationScenarioList) - Parameters:
successAuthenticationScenarioList
- Successful scenarios
-
MockAuthenticationProvider
public MockAuthenticationProvider(List<SuccessAuthenticationScenario> successAuthenticationScenarioList, List<FailedAuthenticationScenario> failedAuthenticationScenarioList) - Parameters:
successAuthenticationScenarioList
- Successful scenariosfailedAuthenticationScenarioList
- Failure scenarios
-
-
Method Details
-
authenticate
public org.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<I, S> authenticationRequest) Description copied from interface:ReactiveAuthenticationProvider
Authenticates a user with the given request. If a successful authentication is returned, the object must be an instance ofAuthentication
. Publishers MUST emit cold observables! This method will be called for all authenticators for each authentication request and it is assumed no work will be done until the publisher is subscribed to.- Specified by:
authenticate
in interfaceReactiveAuthenticationProvider<T,
I, S> - Parameters:
requestContext
- rquest context (it may be an HTTP request).authenticationRequest
- The credentials to authenticate- Returns:
- A publisher that emits 0 or 1 responses
-