Fix failing test AdminEventQueryTest by adding required session parameter (#34612)

Closes #34611

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
Alexander Schwartz 2024-11-04 12:28:59 +01:00 committed by GitHub
parent 8855cf2316
commit 8be4237fd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,7 +41,6 @@ import org.keycloak.testsuite.model.KeycloakModelTest;
import org.keycloak.testsuite.model.RequireProvider;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RequireProvider(EventStoreProvider.class)
@ -70,10 +69,10 @@ public class AdminEventQueryTest extends KeycloakModelTest {
public void testQuery() {
withRealm(realmId, (session, realm) -> {
EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class);
eventStore.onEvent(createClientEvent(realm, OperationType.CREATE), false);
eventStore.onEvent(createClientEvent(realm, OperationType.UPDATE), false);
eventStore.onEvent(createClientEvent(realm, OperationType.DELETE), false);
eventStore.onEvent(createClientEvent(realm, OperationType.CREATE), false);
eventStore.onEvent(createClientEvent(realm, session, OperationType.CREATE), false);
eventStore.onEvent(createClientEvent(realm, session, OperationType.UPDATE), false);
eventStore.onEvent(createClientEvent(realm, session, OperationType.DELETE), false);
eventStore.onEvent(createClientEvent(realm, session, OperationType.CREATE), false);
return null;
});
@ -93,9 +92,9 @@ public class AdminEventQueryTest extends KeycloakModelTest {
public void testQueryOrder() {
withRealm(realmId, (session, realm) -> {
EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class);
AdminEvent firstEvent = createClientEvent(realm, OperationType.CREATE);
AdminEvent firstEvent = createClientEvent(realm, session, OperationType.CREATE);
firstEvent.setTime(1L);
AdminEvent secondEvent = createClientEvent(realm, OperationType.DELETE);
AdminEvent secondEvent = createClientEvent(realm, session, OperationType.DELETE);
secondEvent.setTime(2L);
eventStore.onEvent(firstEvent, false);
eventStore.onEvent(secondEvent, false);
@ -126,7 +125,7 @@ public class AdminEventQueryTest extends KeycloakModelTest {
withRealm(realmId, (session, realm) -> {
AdminEvent event = createClientEvent(realm, OperationType.CREATE);
AdminEvent event = createClientEvent(realm, session, OperationType.CREATE);
event.setRepresentation(longValue);
session.getProvider(EventStoreProvider.class).onEvent(event, true);
@ -144,8 +143,8 @@ public class AdminEventQueryTest extends KeycloakModelTest {
});
}
private AdminEvent createClientEvent(RealmModel realm, OperationType operation) {
return new AdminEventBuilder(realm, new DummyAuth(realm), null, DummyClientConnection.DUMMY_CONNECTION)
private AdminEvent createClientEvent(RealmModel realm, KeycloakSession session, OperationType operation) {
return new AdminEventBuilder(realm, new DummyAuth(realm), session, DummyClientConnection.DUMMY_CONNECTION)
.resource(ResourceType.CLIENT).operation(operation).getEvent();
}