ResourceType lost during clonning
Co-authored-by: Alexander Schwartz <alexander.schwartz@gmx.net> Closes #20947
This commit is contained in:
parent
a0d1ac6baa
commit
7fe7dfc529
2 changed files with 17 additions and 10 deletions
|
@ -51,23 +51,27 @@ public class AdminEventBuilder {
|
|||
private EventStoreProvider store;
|
||||
|
||||
public AdminEventBuilder(RealmModel realm, AdminAuth auth, KeycloakSession session, ClientConnection clientConnection) {
|
||||
this(realm, auth, session, clientConnection.getRemoteAddr());
|
||||
this(realm, auth, session, clientConnection.getRemoteAddr(), null);
|
||||
}
|
||||
|
||||
private AdminEventBuilder(RealmModel realm, AdminAuth auth, KeycloakSession session, String ipAddress) {
|
||||
private AdminEventBuilder(RealmModel realm, AdminAuth auth, KeycloakSession session, String ipAddress, AdminEvent adminEvent) {
|
||||
this.realm = realm;
|
||||
adminEvent = new AdminEvent();
|
||||
|
||||
this.listeners = new HashMap<>();
|
||||
updateStore(session);
|
||||
addListeners(session);
|
||||
this.auth = auth;
|
||||
this.ipAddress = ipAddress;
|
||||
realm(realm);
|
||||
authRealm(auth.getRealm());
|
||||
authClient(auth.getClient());
|
||||
authUser(auth.getUser());
|
||||
authIpAddress(ipAddress);
|
||||
if (adminEvent != null) {
|
||||
this.adminEvent = new AdminEvent(adminEvent);
|
||||
} else {
|
||||
this.adminEvent = new AdminEvent();
|
||||
// Assumption: the following methods write information to the adminEvent only
|
||||
realm(realm);
|
||||
authRealm(auth.getRealm());
|
||||
authClient(auth.getClient());
|
||||
authUser(auth.getUser());
|
||||
authIpAddress(ipAddress);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +90,8 @@ public class AdminEventBuilder {
|
|||
newEventRealm,
|
||||
new AdminAuth(newAuthRealm, this.auth.getToken(), newAuthUser, newAuthClient),
|
||||
session,
|
||||
ipAddress
|
||||
ipAddress,
|
||||
adminEvent
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ import static org.hamcrest.CoreMatchers.hasItem;
|
|||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -400,6 +401,7 @@ public class PartialImportTest extends AbstractAuthTest {
|
|||
Assert.assertEquals(realmId, adminEvent.getRealmId());
|
||||
Assert.assertEquals(OperationType.CREATE.name(), adminEvent.getOperationType());
|
||||
Assert.assertTrue(adminEvent.getResourcePath().startsWith("users/"));
|
||||
assertThat(adminEvent.getResourceType(), equalTo(org.keycloak.events.admin.ResourceType.REALM.name()));
|
||||
String userId = adminEvent.getResourcePath().substring(6);
|
||||
userIds.add(userId);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue