Search in sources :

Example 1 with InterceptingLogger

use of org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger in project uaa by cloudfoundry.

the class AuditCheckMockMvcTests method setUp.

@BeforeEach
void setUp(@Autowired FilterChainProxy springSecurityFilterChain, @Autowired WebApplicationContext webApplicationContext) throws Exception {
    mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).addFilter(springSecurityFilterChain).build();
    testClient = new TestClient(mockMvc);
    originalLoginClient = clientRegistrationService.loadClientByClientId("login");
    testAccounts = UaaTestAccounts.standard(null);
    mockAuditService = mock(UaaAuditService.class);
    testListener = TestApplicationEventListener.forEventClass(AbstractUaaEvent.class);
    configurableApplicationContext.addApplicationListener(testListener);
    auditListener = new AuditListener(mockAuditService);
    configurableApplicationContext.addApplicationListener(auditListener);
    testLogger = new InterceptingLogger();
    originalAuditServiceLogger = loggingAuditService.getLogger();
    loggingAuditService.setLogger(testLogger);
    adminToken = testClient.getClientCredentialsOAuthAccessToken(testAccounts.getAdminClientId(), testAccounts.getAdminClientSecret(), "uaa.admin,scim.write");
    testUser = createUser(adminToken, "testUser", "Test", "User", "testuser@test.com", testPassword, true);
    resetAuditTestReceivers();
    authSuccessListener = mock(new DefaultApplicationListener<UserAuthenticationSuccessEvent>() {
    }.getClass());
    configurableApplicationContext.addApplicationListener(authSuccessListener);
    mgr.setAllowUnverifiedUsers(false);
}
Also used : AbstractUaaEvent(org.cloudfoundry.identity.uaa.audit.event.AbstractUaaEvent) AuditListener(org.cloudfoundry.identity.uaa.audit.event.AuditListener) InterceptingLogger(org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with InterceptingLogger

use of org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger 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);
}
Also used : AbstractUaaEvent(org.cloudfoundry.identity.uaa.audit.event.AbstractUaaEvent) RandomValueStringGenerator(org.springframework.security.oauth2.common.util.RandomValueStringGenerator) InterceptingLogger(org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger) LdapIdentityProviderDefinition(org.cloudfoundry.identity.uaa.provider.LdapIdentityProviderDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with InterceptingLogger

use of org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger in project uaa by cloudfoundry.

the class SamlAuthenticationMockMvcTests method installTestLogger.

@BeforeEach
void installTestLogger() {
    testLogger = new InterceptingLogger();
    originalAuditServiceLogger = loggingAuditService.getLogger();
    loggingAuditService.setLogger(testLogger);
}
Also used : InterceptingLogger(org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

InterceptingLogger (org.cloudfoundry.identity.uaa.mock.util.InterceptingLogger)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 AbstractUaaEvent (org.cloudfoundry.identity.uaa.audit.event.AbstractUaaEvent)2 AuditListener (org.cloudfoundry.identity.uaa.audit.event.AuditListener)1 LdapIdentityProviderDefinition (org.cloudfoundry.identity.uaa.provider.LdapIdentityProviderDefinition)1 RandomValueStringGenerator (org.springframework.security.oauth2.common.util.RandomValueStringGenerator)1