@Test
public void testDirectClientThrowsRequiresHttpAction(final TestContext testContext) throws Exception {
final AsyncClient directClient = getMockDirectClient(NAME, TEST_CREDENTIALS);
final Clients<AsyncClient<? extends Credentials, ? extends CommonProfile>, AsyncAuthorizationGenerator<CommonProfile>> clients = new Clients<>(CALLBACK_URL, directClient);
when(config.getClients()).thenReturn(clients);
final String clientNames = NAME;
asyncSecurityLogic = new DefaultAsyncSecurityLogic<>(true, false, config, httpActionAdapter);
when(directClient.getCredentials(eq(webContext))).thenReturn(delayedException(250,
(() -> HttpAction.status("bad request", 400, webContext))));
final Async async = testContext.async();
final CompletableFuture<Object> result = asyncSecurityLogic.perform(webContext, accessGrantedAdapter, clientNames, null, null);
exception.expect(CompletionException.class);
exception.expectCause(allOf(IsInstanceOf.instanceOf(HttpAction.class),
hasProperty("message", is("bad request")),
hasProperty("code", is(400))));
assertSuccessfulEvaluation(result, ExceptionSoftener.softenConsumer(o -> {
assertThat(o, is(nullValue()));
assertThat(status.get(), is(400));
verify(accessGrantedAdapter, times(0)).adapt(webContext);
}), async);
}
DefaultAsyncSecurityLogicTest.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:pac4j-async
作者:
评论列表
文章目录