use of org.keycloak.representations.idm.AdminEventRepresentation in project keycloak by keycloak.
the class UserTotpTest method setupTotp.
@Test
public void setupTotp() {
totpPage.open();
loginPage.login("test-user@localhost", "password");
events.expectLogin().client("account").detail(Details.REDIRECT_URI, getAccountRedirectUrl() + "?path=totp").assertEvent();
Assert.assertTrue(totpPage.isCurrent());
Assert.assertFalse(driver.getPageSource().contains("Remove Google"));
totpPage.configure(totp.generateTOTP(totpPage.getTotpSecret()));
Assert.assertEquals("Mobile authenticator configured.", profilePage.getSuccess());
events.expectAccount(EventType.UPDATE_TOTP).assertEvent();
Assert.assertTrue(driver.getPageSource().contains("pficon-delete"));
List<UserRepresentation> users = adminClient.realms().realm("test").users().search("test-user@localhost", null, null, null, 0, 1);
String userId = users.get(0).getId();
testingClient.testing().clearAdminEventQueue();
CredentialRepresentation totpCredential = adminClient.realms().realm("test").users().get(userId).credentials().stream().filter(c -> OTPCredentialModel.TYPE.equals(c.getType())).findFirst().get();
adminClient.realms().realm("test").users().get(userId).removeCredential(totpCredential.getId());
totpPage.open();
Assert.assertFalse(driver.getPageSource().contains("pficon-delete"));
AdminEventRepresentation event = testingClient.testing().pollAdminEvent();
Assert.assertNotNull(event);
Assert.assertEquals(OperationType.ACTION.name(), event.getOperationType());
Assert.assertEquals("users/" + userId + "/credentials/" + totpCredential.getId(), event.getResourcePath());
}
use of org.keycloak.representations.idm.AdminEventRepresentation in project keycloak by keycloak.
the class AdminEventStoreProviderTest method create.
private AdminEventRepresentation create(long time, String realmId, OperationType operation, String authRealmId, String authClientId, String authUserId, String authIpAddress, String resourcePath, String resourceType, String error) {
AdminEventRepresentation e = new AdminEventRepresentation();
e.setTime(time);
e.setRealmId(realmId);
e.setOperationType(operation.toString());
AuthDetailsRepresentation authDetails = new AuthDetailsRepresentation();
authDetails.setRealmId(authRealmId);
authDetails.setClientId(authClientId);
authDetails.setUserId(authUserId);
authDetails.setIpAddress(authIpAddress);
e.setAuthDetails(authDetails);
e.setResourcePath(resourcePath);
e.setResourceType(resourceType);
e.setError(error);
return e;
}
use of org.keycloak.representations.idm.AdminEventRepresentation in project keycloak by keycloak.
the class AdminEventTest method testGetRepresentation.
@Test
public void testGetRepresentation() {
configRep.setAdminEventsDetailsEnabled(Boolean.TRUE);
saveConfig();
createUser("user2");
AdminEventRepresentation event = events().stream().filter(adminEventRep -> adminEventRep.getOperationType().equals("CREATE")).findFirst().orElseThrow(() -> new IllegalStateException("Wasn't able to obtain CREATE admin event."));
assertThat(event.getRepresentation(), is(notNullValue()));
assertThat(event.getRepresentation(), allOf(containsString("foo"), containsString("bar")));
}
use of org.keycloak.representations.idm.AdminEventRepresentation in project keycloak by keycloak.
the class AdminEventTest method adminEventAttributeTest.
@Test
public void adminEventAttributeTest() {
createUser("user5");
List<AdminEventRepresentation> events = events();
assertThat(events().size(), is(equalTo(1)));
AdminEventRepresentation event = events.get(0);
assertThat(event.getTime(), is(greaterThan(0L)));
assertThat(event.getRealmId(), is(equalTo(realmName())));
assertThat(event.getOperationType(), is(equalTo("CREATE")));
assertThat(event.getResourcePath(), is(notNullValue()));
assertThat(event.getError(), is(nullValue()));
AuthDetailsRepresentation details = event.getAuthDetails();
assertThat(details.getRealmId(), is(equalTo("master")));
assertThat(details.getClientId(), is(notNullValue()));
assertThat(details.getUserId(), is(notNullValue()));
assertThat(details.getIpAddress(), is(notNullValue()));
}
use of org.keycloak.representations.idm.AdminEventRepresentation in project keycloak by keycloak.
the class AdminEventTest method checkUpdateRealmEventsConfigEvent.
private void checkUpdateRealmEventsConfigEvent(int size) {
List<AdminEventRepresentation> events = events();
assertThat(events.size(), is(equalTo(size)));
AdminEventRepresentation event = events().get(0);
assertThat(event.getOperationType(), is(equalTo("UPDATE")));
assertThat(event.getRealmId(), is(equalTo(realmName())));
assertThat(event.getResourcePath(), is(equalTo("events/config")));
assertThat(event.getAuthDetails().getRealmId(), is(equalTo("master")));
assertThat(event.getRepresentation(), is(notNullValue()));
}
Aggregations