@Test public void testLoginSuccess() throws Exception { SecurityContextHolder.getContext().setAuthentication(this.auth); assertThat(this.module.login()) .as("Login should succeed, there is an authentication set").isTrue(); assertThat(this.module.commit()) .withFailMessage( "The authentication is not null, this should return true") .isTrue(); assertThat(this.subject.getPrincipals().contains(this.auth)) .withFailMessage("Principals should contain the authentication").isTrue(); }
@Test public void testAbort() throws Exception { assertThat(this.module.abort()).as("Should return false, no auth is set") .isFalse(); SecurityContextHolder.getContext().setAuthentication(this.auth); this.module.login(); this.module.commit(); assertThat(this.module.abort()).isTrue(); }