QueryParameterAccessTokenAuthenticationStrategy implements AuthenticationStrategy { @Override public Mono<MailboxSession> createMailboxSession(HttpServerRequest httpRequest) { return Mono.justOrEmpty(getAccessToken(httpRequest)) .filter(tokenManager::isValid) .map(AttachmentAccessToken::getUsername) .map(Username::of) .map(mailboxManager::createSystemSession); } @Inject @VisibleForTesting  QueryParameterAccessTokenAuthenticationStrategy(SimpleTokenManager tokenManager, MailboxManager mailboxManager); @Override Mono<MailboxSession> createMailboxSession(HttpServerRequest httpRequest);  }
@Test public void createMailboxSessionShouldThrowWhenNoAccessTokenProvided() { when(mockedRequest.param("access_token")) .thenReturn(null); assertThat(testee.createMailboxSession(mockedRequest).blockOptional()) .isEmpty(); }
@Test public void createMailboxSessionShouldThrowWhenAccessTokenIsNotValid() { when(mockedRequest.param("access_token")) .thenReturn("bad"); assertThat(testee.createMailboxSession(mockedRequest).blockOptional()) .isEmpty(); }