use of org.cloudfoundry.identity.uaa.audit.event.AbstractUaaEvent in project uaa by cloudfoundry.
the class AbstractLdapMockMvcTest method setUp.
@BeforeEach
void setUp(@Autowired WebApplicationContext webApplicationContext, @Autowired MockMvc mockMvc, @Autowired ConfigurableApplicationContext configurableApplicationContext, @Autowired JdbcScimUserProvisioning jdbcScimUserProvisioning, @Autowired LoggingAuditService loggingAuditService) throws Exception {
this.webApplicationContext = webApplicationContext;
this.mockMvc = mockMvc;
this.jdbcScimUserProvisioning = jdbcScimUserProvisioning;
this.loggingAuditService = loggingAuditService;
String userId = new RandomValueStringGenerator().generate().toLowerCase();
zone = MockMvcUtils.createZoneForInvites(getMockMvc(), getWebApplicationContext(), userId, REDIRECT_URI, IdentityZoneHolder.getCurrentZoneId());
LdapIdentityProviderDefinition definition = new LdapIdentityProviderDefinition();
definition.setLdapProfileFile("ldap/" + ldapProfile);
definition.setLdapGroupFile("ldap/" + ldapGroup);
definition.setMaxGroupSearchDepth(10);
definition.setBaseUrl(getLdapOrLdapSBaseUrl());
definition.setBindUserDn("cn=admin,ou=Users,dc=test,dc=com");
definition.setBindPassword("adminsecret");
definition.setSkipSSLVerification(false);
definition.setTlsConfiguration(tlsConfig);
definition.setMailAttributeName("mail");
definition.setReferral("ignore");
provider = MockMvcUtils.createIdentityProvider(getMockMvc(), zone.getZone(), LDAP, definition);
host = zone.getZone().getIdentityZone().getSubdomain() + ".localhost";
IdentityZoneHolder.clear();
listener = (ApplicationListener<AbstractUaaEvent>) mock(ApplicationListener.class);
configurableApplicationContext.addApplicationListener(listener);
ensureLdapServerIsRunning();
testLogger = new InterceptingLogger();
originalAuditServiceLogger = loggingAuditService.getLogger();
loggingAuditService.setLogger(testLogger);
}
use of org.cloudfoundry.identity.uaa.audit.event.AbstractUaaEvent in project uaa by cloudfoundry.
the class AbstractLdapMockMvcTest method testAuthenticateFailure.
@Test
void testAuthenticateFailure() throws Exception {
String username = "marissa3";
String password = "ldapsadadasas";
MockHttpServletRequestBuilder post = post("/authenticate").header(HOST, host).accept(MediaType.APPLICATION_JSON).param("username", username).param("password", password);
getMockMvc().perform(post).andExpect(status().isUnauthorized());
ArgumentCaptor<AbstractUaaEvent> captor = ArgumentCaptor.forClass(AbstractUaaEvent.class);
verify(listener, atLeast(5)).onApplicationEvent(captor.capture());
List<AbstractUaaEvent> allValues = captor.getAllValues();
assertThat(allValues.get(4), instanceOf(IdentityProviderAuthenticationFailureEvent.class));
IdentityProviderAuthenticationFailureEvent event = (IdentityProviderAuthenticationFailureEvent) allValues.get(4);
assertEquals("marissa3", event.getUsername());
assertEquals(OriginKeys.LDAP, event.getAuthenticationType());
}
Aggregations