Search in sources :

Example 1 with AuthenticationHandler

use of io.gravitee.gateway.security.core.AuthenticationHandler in project gravitee-gateway by gravitee-io.

the class PlanBasedAuthenticationHandlerEnhancerTest method shouldResolveKeylessPolicy_becauseOnePlanKeyless.

@Test
public void shouldResolveKeylessPolicy_becauseOnePlanKeyless() {
    AuthenticationHandler authenticationHandler = mock(AuthenticationHandler.class);
    when(authenticationHandler.name()).thenReturn("keyless");
    Plan plan1 = new Plan();
    plan1.setSecurity("keyless");
    when(api.getPlans()).thenReturn(Collections.singletonList(plan1));
    List<AuthenticationHandler> SecurityProviders = authenticationHandlerEnhancer.filter(Collections.singletonList(authenticationHandler));
    assertNotNull(SecurityProviders);
    assertFalse(SecurityProviders.isEmpty());
    assertEquals("keyless", SecurityProviders.iterator().next().name());
}
Also used : AuthenticationHandler(io.gravitee.gateway.security.core.AuthenticationHandler) Plan(io.gravitee.gateway.handlers.api.definition.Plan) Test(org.junit.Test)

Example 2 with AuthenticationHandler

use of io.gravitee.gateway.security.core.AuthenticationHandler in project gravitee-gateway by gravitee-io.

the class PlanBasedAuthenticationHandlerEnhancerTest method shouldNotResolveKeylessPolicy_becauseOnePlanApikey.

@Test
public void shouldNotResolveKeylessPolicy_becauseOnePlanApikey() {
    AuthenticationHandler authenticationHandler = mock(AuthenticationHandler.class);
    when(authenticationHandler.name()).thenReturn("keyless");
    Plan plan1 = new Plan();
    plan1.setSecurity("apikey");
    when(api.getPlans()).thenReturn(Collections.singletonList(plan1));
    List<AuthenticationHandler> SecurityProviders = authenticationHandlerEnhancer.filter(Collections.singletonList(authenticationHandler));
    assertNotNull(SecurityProviders);
    assertTrue(SecurityProviders.isEmpty());
}
Also used : AuthenticationHandler(io.gravitee.gateway.security.core.AuthenticationHandler) Plan(io.gravitee.gateway.handlers.api.definition.Plan) Test(org.junit.Test)

Example 3 with AuthenticationHandler

use of io.gravitee.gateway.security.core.AuthenticationHandler in project gravitee-gateway by gravitee-io.

the class PlanBasedAuthenticationHandlerEnhancerTest method shouldNotResolveKeylessPolicy_becauseNoPlan.

@Test
public void shouldNotResolveKeylessPolicy_becauseNoPlan() {
    AuthenticationHandler authenticationHandler = mock(AuthenticationHandler.class);
    when(authenticationHandler.name()).thenReturn("keyless");
    List<AuthenticationHandler> SecurityProviders = authenticationHandlerEnhancer.filter(Collections.singletonList(authenticationHandler));
    assertNotNull(SecurityProviders);
    assertTrue(SecurityProviders.isEmpty());
}
Also used : AuthenticationHandler(io.gravitee.gateway.security.core.AuthenticationHandler) Test(org.junit.Test)

Aggregations

AuthenticationHandler (io.gravitee.gateway.security.core.AuthenticationHandler)3 Test (org.junit.Test)3 Plan (io.gravitee.gateway.handlers.api.definition.Plan)2