Fix event tests
This commit is contained in:
parent
3e58d3da8d
commit
38442ee0a6
4 changed files with 173 additions and 157 deletions
|
@ -306,15 +306,6 @@ public class TestingResourceProvider implements RealmResourceProvider {
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/clear-event-store")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public Response clearEventStore() {
|
|
||||||
EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class);
|
|
||||||
eventStore.clear();
|
|
||||||
return Response.noContent().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/clear-event-store-for-realm")
|
@Path("/clear-event-store-for-realm")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -435,15 +426,6 @@ public class TestingResourceProvider implements RealmResourceProvider {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/clear-admin-event-store")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public Response clearAdminEventStore() {
|
|
||||||
EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class);
|
|
||||||
eventStore.clearAdmin();
|
|
||||||
return Response.noContent().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/clear-admin-event-store-for-realm")
|
@Path("/clear-admin-event-store-for-realm")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
|
|
@ -82,11 +82,6 @@ public interface TestingResource {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
void clearAdminEventQueue();
|
void clearAdminEventQueue();
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/clear-event-store")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
void clearEventStore();
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/clear-event-store-for-realm")
|
@Path("/clear-event-store-for-realm")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -127,11 +122,6 @@ public interface TestingResource {
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public void onEvent(final EventRepresentation rep);
|
public void onEvent(final EventRepresentation rep);
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/clear-admin-event-store")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
void clearAdminEventStore();
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/clear-admin-event-store-for-realm")
|
@Path("/clear-admin-event-store-for-realm")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
testing().clearAdminEventStore();
|
testing().clearAdminEventStore(realmId);
|
||||||
|
testing().clearAdminEventStore(realmId2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,87 +64,105 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
testing().onAdminEvent(create(oldest, realmId, OperationType.CREATE, realmId, "clientId2", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(oldest, realmId, OperationType.CREATE, realmId, "clientId2", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
|
|
||||||
Assert.assertEquals(5, testing().getAdminEvents(null, null, null, "clientId", null, null, null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, null, null, "clientId", null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(5, testing().getAdminEvents(null, null, realmId, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, "clientId", null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, realmId, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(3, testing().getAdminEvents(realmId, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, "userId", null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(3, testing().getAdminEvents(realmId, null, null, null, "userId", null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, "userId", null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(1, testing().getAdminEvents(null, toList(OperationType.ACTION), null, null, "userId", null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId, toList(OperationType.ACTION), null, null, "userId", null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, toList(OperationType.ACTION), null, null, "userId", null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(2, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, 2).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, 2).size());
|
||||||
Assert.assertEquals(1, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, 5, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, 4, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(newest, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, 1).get(0).getTime());
|
Assert.assertEquals(newest, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, 1).get(0).getTime());
|
||||||
Assert.assertEquals(oldest, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, 5, 1).get(0).getTime());
|
Assert.assertEquals(oldest, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, 4, 1).get(0).getTime());
|
||||||
|
|
||||||
testing().clearAdminEventStore(realmId);
|
testing().clearAdminEventStore(realmId);
|
||||||
testing().clearAdminEventStore(realmId2);
|
testing().clearAdminEventStore(realmId2);
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
String d1 = "2015-03-04";
|
String d04 = "2015-03-04";
|
||||||
String d2 = "2015-03-05";
|
String d05 = "2015-03-05";
|
||||||
String d3 = "2015-03-06";
|
String d06 = "2015-03-06";
|
||||||
String d4 = "2015-03-07";
|
String d07 = "2015-03-07";
|
||||||
|
|
||||||
String d5 = "2015-03-01";
|
String d01 = "2015-03-01";
|
||||||
String d6 = "2015-03-03";
|
String d03 = "2015-03-03";
|
||||||
String d7 = "2015-03-08";
|
String d08 = "2015-03-08";
|
||||||
String d8 = "2015-03-10";
|
String d10 = "2015-03-10";
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
Date date1 = null, date2 = null, date3 = null, date4 = null;
|
Date date04 = null, date05 = null, date06 = null, date07 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
date1 = formatter.parse(d1);
|
date04 = formatter.parse(d04);
|
||||||
date2 = formatter.parse(d2);
|
date05 = formatter.parse(d05);
|
||||||
date3 = formatter.parse(d3);
|
date06 = formatter.parse(d06);
|
||||||
date4 = formatter.parse(d4);
|
date07 = formatter.parse(d07);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
testing().onAdminEvent(create(date1, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date04, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date1, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date04, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date2, realmId, OperationType.ACTION, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date05, realmId, OperationType.ACTION, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date2, realmId, OperationType.ACTION, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date05, realmId, OperationType.ACTION, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date3, realmId, OperationType.UPDATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date06, realmId, OperationType.UPDATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date3, realmId, OperationType.DELETE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date06, realmId, OperationType.DELETE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date4, realmId2, OperationType.CREATE, realmId2, "clientId2", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date07, realmId2, OperationType.CREATE, realmId2, "clientId2", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(date4, realmId2, OperationType.CREATE, realmId2, "clientId2", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(date07, realmId2, OperationType.CREATE, realmId2, "clientId2", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
|
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, "clientId", null, null, null, null, null, null, null).size());
|
Assert.assertEquals(6, testing().getAdminEvents(realmId, null, null, "clientId", null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(2, testing().getAdminEvents(null, null, null, "clientId2", null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, "clientId", null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, "clientId2", null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, "clientId2", null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, realmId, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(6, testing().getAdminEvents(realmId, null, realmId, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(2, testing().getAdminEvents(null, null, realmId2, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, "userId", null, null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, null, null, null, "userId", null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, "userId2", null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, "userId2", null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, "userId2", null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(2, testing().getAdminEvents(null, toList(OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, toList(OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().getAdminEvents(null, toList(OperationType.UPDATE), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, toList(OperationType.CREATE, OperationType.ACTION), null, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().getAdminEvents(null, toList(OperationType.DELETE), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId, toList(OperationType.UPDATE), null, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().getAdminEvents(realmId, toList(OperationType.DELETE), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, toList(OperationType.CREATE), null, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(8, testing().getAdminEvents(null, null, null, null, null, null, null, d1, null, null, null).size());
|
Assert.assertEquals(6, testing().getAdminEvents(realmId, null, null, null, null, null, null, d04, null, null, null).size());
|
||||||
Assert.assertEquals(8, testing().getAdminEvents(null, null, null, null, null, null, null, null, d4, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d04, null, null, null).size());
|
||||||
|
Assert.assertEquals(6, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, d07, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, d07, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, null, null, null, d3, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, d06, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, null, null, null, null, d2, null, null).size());
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, d05, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(null, null, null, null, null, null, null, d7, null, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d08, null, null, null).size());
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(null, null, null, null, null, null, null, null, d6, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, d03, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(8, testing().getAdminEvents(null, null, null, null, null, null, null, d1, d4, null, null).size());
|
Assert.assertEquals(6, testing().getAdminEvents(realmId, null, null, null, null, null, null, d04, d07, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, null, d2, d4, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d04, d07, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, null, null, null, d1, d2, null, null).size());
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, null, null, null, null, null, null, d05, d07, null, null).size());
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, null, null, null, d3, d4, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d05, d07, null, null).size());
|
||||||
|
Assert.assertEquals(4, testing().getAdminEvents(realmId, null, null, null, null, null, null, d04, d05, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, d06, d07, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d06, d07, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(null, null, null, null, null, null, null, d5, d6, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, null, null, null, null, d01, d03, null, null).size());
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(null, null, null, null, null, null, null, d7, d8, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d01, d03, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, null, null, null, null, d08, d10, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, d08, d10, null, null).size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +178,21 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
testing().onAdminEvent(create(oldest, realmId, OperationType.CREATE, realmId, "clientId2", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(oldest, realmId, OperationType.CREATE, realmId, "clientId2", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||||
|
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/*", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "/admin/*", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/realms/*", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "*/realms/*", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/master", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "*/master", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/realms/*", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "/admin/realms/*", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/realms/master", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "*/realms/master", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/*/master", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "/admin/*/master", null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/ad*/*/master", null, null, null, null).size());
|
Assert.assertEquals(5, testing().getAdminEvents(realmId, null, null, null, null, null, "/ad*/*/master", null, null, null, null).size());
|
||||||
|
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "/admin/*", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "*/realms/*", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "*/master", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "/admin/realms/*", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "*/realms/master", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "/admin/*/master", null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, "/ad*/*/master", null, null, null, null).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -178,7 +205,8 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
testing().clearAdminEventStore(realmId);
|
testing().clearAdminEventStore(realmId);
|
||||||
|
|
||||||
Assert.assertEquals(1, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -191,7 +219,7 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
testing().clearAdminEventStore(realmId, System.currentTimeMillis() - 10000);
|
testing().clearAdminEventStore(realmId, System.currentTimeMillis() - 10000);
|
||||||
|
|
||||||
Assert.assertEquals(2, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -213,7 +241,8 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
// The first 2 events from realmId will be deleted
|
// The first 2 events from realmId will be deleted
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(4, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// Set expiration of events for realmId2 as well
|
// Set expiration of events for realmId2 as well
|
||||||
RealmRepresentation realm2 = realmsResouce().realm(REALM_NAME_2).toRepresentation();
|
RealmRepresentation realm2 = realmsResouce().realm(REALM_NAME_2).toRepresentation();
|
||||||
|
@ -224,12 +253,14 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
// The first event from realmId2 will be deleted now
|
// The first event from realmId2 will be deleted now
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(3, testing().getAdminEvents(null, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// set time offset to the future. The remaining 2 events from realmId and 1 event from realmId2 should be expired now
|
// set time offset to the future. The remaining 2 events from realmId and 1 event from realmId2 should be expired now
|
||||||
setTimeOffset(150);
|
setTimeOffset(150);
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(0, testing().getAdminEvents(REALM_NAME_1, null, null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().getAdminEvents(realmId, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().getAdminEvents(realmId2, null, null, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// Revert expirations
|
// Revert expirations
|
||||||
attributes.put(RealmAttributes.ADMIN_EVENTS_EXPIRATION,"0");
|
attributes.put(RealmAttributes.ADMIN_EVENTS_EXPIRATION,"0");
|
||||||
|
@ -244,7 +275,7 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
||||||
public void handleCustomResourceTypeEvents() {
|
public void handleCustomResourceTypeEvents() {
|
||||||
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "my-custom-resource", "error"), false);
|
testing().onAdminEvent(create(realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "my-custom-resource", "error"), false);
|
||||||
|
|
||||||
List<AdminEventRepresentation> adminEvents = testing().getAdminEvents(null, null, null, "clientId", null, null, null, null, null, null, null);
|
List<AdminEventRepresentation> adminEvents = testing().getAdminEvents(realmId, null, null, "clientId", null, null, null, null, null, null, null);
|
||||||
Assert.assertEquals(1, adminEvents.size());
|
Assert.assertEquals(1, adminEvents.size());
|
||||||
Assert.assertEquals("my-custom-resource", adminEvents.get(0).getResourceType());
|
Assert.assertEquals("my-custom-resource", adminEvents.get(0).getResourceType());
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
testing().clearEventStore();
|
testing().clearEventStore(realmId);
|
||||||
|
testing().clearEventStore(realmId2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -77,89 +78,97 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
testing().onEvent(create(oldest, EventType.LOGIN, realmId, "clientId2", "userId", "127.0.0.1", "error"));
|
testing().onEvent(create(oldest, EventType.LOGIN, realmId, "clientId2", "userId", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(EventType.LOGIN, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
testing().onEvent(create(EventType.LOGIN, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
||||||
|
|
||||||
Assert.assertEquals(5, testing().queryEvents(null, null, "clientId", null, null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().queryEvents(realmId, null, "clientId", null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(5, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(5, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, toList(EventType.LOGIN), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(3, testing().queryEvents(realmId, toList(EventType.LOGIN), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().queryEvents(null, toList(EventType.LOGIN, EventType.REGISTER), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId2, toList(EventType.LOGIN), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, "userId", null, null, null, null, null).size());
|
Assert.assertEquals(5, testing().queryEvents(realmId, toList(EventType.LOGIN, EventType.REGISTER), null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().queryEvents(realmId2, toList(EventType.LOGIN, EventType.REGISTER), null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(3, testing().queryEvents(realmId, null, null, "userId", null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, toList(EventType.REGISTER), null, "userId", null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId, toList(EventType.REGISTER), null, "userId", null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(2, testing().queryEvents(null, null, null, null, null, null, null, null, 2).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, null, null, null, null, null, 2).size());
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, null, null, null, null, null, null, 5, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId, null, null, null, null, null, null, 4, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(newest, testing().queryEvents(null, null, null, null, null, null, null, null, 1).get(0).getTime());
|
Assert.assertEquals(newest, testing().queryEvents(realmId, null, null, null, null, null, null, null, 1).get(0).getTime());
|
||||||
Assert.assertEquals(oldest, testing().queryEvents(null, null, null, null, null, null, null, 5, 1).get(0).getTime());
|
Assert.assertEquals(oldest, testing().queryEvents(realmId, null, null, null, null, null, null, 4, 1).get(0).getTime());
|
||||||
|
|
||||||
testing().clearEventStore(realmId);
|
testing().clearEventStore(realmId);
|
||||||
testing().clearEventStore(realmId2);
|
testing().clearEventStore(realmId2);
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
String d1 = "2015-03-04";
|
String d04 = "2015-03-04";
|
||||||
String d2 = "2015-03-05";
|
String d05 = "2015-03-05";
|
||||||
String d3 = "2015-03-06";
|
String d06 = "2015-03-06";
|
||||||
String d4 = "2015-03-07";
|
String d07 = "2015-03-07";
|
||||||
|
|
||||||
String d5 = "2015-03-01";
|
String d01 = "2015-03-01";
|
||||||
String d6 = "2015-03-03";
|
String d03 = "2015-03-03";
|
||||||
String d7 = "2015-03-08";
|
String d08 = "2015-03-08";
|
||||||
String d8 = "2015-03-10";
|
String d10 = "2015-03-10";
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
Date date1 = null, date2 = null, date3 = null, date4 = null;
|
Date date04 = null, date05 = null, date06 = null, date07 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
date1 = formatter.parse(d1);
|
date04 = formatter.parse(d04);
|
||||||
date2 = formatter.parse(d2);
|
date05 = formatter.parse(d05);
|
||||||
date3 = formatter.parse(d3);
|
date06 = formatter.parse(d06);
|
||||||
date4 = formatter.parse(d4);
|
date07 = formatter.parse(d07);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
testing().onEvent(create(date1, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
testing().onEvent(create(date04, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date1, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
testing().onEvent(create(date04, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date2, EventType.REGISTER, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
testing().onEvent(create(date05, EventType.REGISTER, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date2, EventType.REGISTER, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
testing().onEvent(create(date05, EventType.REGISTER, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date3, EventType.CODE_TO_TOKEN, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
testing().onEvent(create(date06, EventType.CODE_TO_TOKEN, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date3, EventType.LOGOUT, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
testing().onEvent(create(date06, EventType.LOGOUT, realmId, "clientId", "userId2", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date4, EventType.UPDATE_PROFILE, realmId2, "clientId2", "userId2", "127.0.0.1", "error"));
|
testing().onEvent(create(date07, EventType.UPDATE_PROFILE, realmId2, "clientId2", "userId2", "127.0.0.1", "error"));
|
||||||
testing().onEvent(create(date4, EventType.UPDATE_EMAIL, realmId2, "clientId2", "userId2", "127.0.0.1", "error"));
|
testing().onEvent(create(date07, EventType.UPDATE_EMAIL, realmId2, "clientId2", "userId2", "127.0.0.1", "error"));
|
||||||
|
|
||||||
Assert.assertEquals(6, testing().queryEvents(null, null, "clientId", null, null, null, null, null, null).size());
|
Assert.assertEquals(6, testing().queryEvents(realmId, null, "clientId", null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(2, testing().queryEvents(null, null, "clientId2", null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, "clientId2", null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(6, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(6, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, "userId", null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().queryEvents(realmId, null, null, "userId", null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, "userId2", null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, "userId2", null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, "userId2", null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(2, testing().queryEvents(null, toList(EventType.LOGIN), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, toList(EventType.LOGIN), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(2, testing().queryEvents(null, toList(EventType.REGISTER), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, toList(EventType.REGISTER), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, toList(EventType.LOGIN, EventType.REGISTER), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(4, testing().queryEvents(realmId, toList(EventType.LOGIN, EventType.REGISTER), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, toList(EventType.CODE_TO_TOKEN), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId, toList(EventType.CODE_TO_TOKEN), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, toList(EventType.LOGOUT), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId, toList(EventType.LOGOUT), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, toList(EventType.UPDATE_PROFILE), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId2, toList(EventType.UPDATE_PROFILE), null, null, null, null, null, null, null).size());
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, toList(EventType.UPDATE_EMAIL), null, null, null, null, null, null, null).size());
|
Assert.assertEquals(1, testing().queryEvents(realmId2, toList(EventType.UPDATE_EMAIL), null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(8, testing().queryEvents(null, null, null, null, d1, null, null, null, null).size());
|
Assert.assertEquals(6, testing().queryEvents(realmId, null, null, null, d04, null, null, null, null).size());
|
||||||
Assert.assertEquals(8, testing().queryEvents(null, null, null, null, null, d4, null, null, null).size());
|
Assert.assertEquals(6, testing().queryEvents(realmId, null, null, null, null, d07, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, null, d3, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, null, d06, null, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, null, null, d2, null, null, null).size());
|
Assert.assertEquals(4, testing().queryEvents(realmId, null, null, null, null, d05, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, d7, null, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId2, null, null, null, d08, null, null, null, null).size());
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, null, d6, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId2, null, null, null, null, d03, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(8, testing().queryEvents(null, null, null, null, d1, d4, null, null, null).size());
|
Assert.assertEquals(6, testing().queryEvents(realmId, null, null, null, d04, d07, null, null, null).size());
|
||||||
Assert.assertEquals(6, testing().queryEvents(null, null, null, null, d2, d4, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, d04, d07, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, null, d1, d2, null, null, null).size());
|
Assert.assertEquals(4, testing().queryEvents(realmId, null, null, null, d05, d07, null, null, null).size());
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, null, d3, d4, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, d05, d07, null, null, null).size());
|
||||||
|
Assert.assertEquals(4, testing().queryEvents(realmId, null, null, null, d04, d05, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, null, d06, d07, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, d06, d07, null, null, null).size());
|
||||||
|
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, d5, d6, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId, null, null, null, d01, d03, null, null, null).size());
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, d7, d8, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId2, null, null, null, d01, d03, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().queryEvents(realmId, null, null, null, d08, d10, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().queryEvents(realmId2, null, null, null, d08, d10, null, null, null).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -172,7 +181,8 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
testing().clearEventStore(realmId);
|
testing().clearEventStore(realmId);
|
||||||
|
|
||||||
Assert.assertEquals(1, testing().queryEvents(null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -185,7 +195,7 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void maxLengthWithNull(){
|
public void maxLengthWithNull(){
|
||||||
testing().onEvent(create(System.currentTimeMillis() - 30000, EventType.LOGIN, null, null, null, "127.0.0.1", "error"));
|
testing().onEvent(create(System.currentTimeMillis() - 30000, EventType.LOGIN, realmId, null, null, "127.0.0.1", "error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -205,7 +215,8 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
// The first 2 events from realmId will be deleted
|
// The first 2 events from realmId will be deleted
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(4, testing().queryEvents(null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(2, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// Set expiration of events for realmId2 as well
|
// Set expiration of events for realmId2 as well
|
||||||
RealmRepresentation realm2 = realmsResouce().realm(REALM_NAME_2).toRepresentation();
|
RealmRepresentation realm2 = realmsResouce().realm(REALM_NAME_2).toRepresentation();
|
||||||
|
@ -214,12 +225,14 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
||||||
|
|
||||||
// The first event from realmId2 will be deleted now
|
// The first event from realmId2 will be deleted now
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(3, testing().queryEvents(null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(2, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(1, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// set time offset to the future. The remaining 2 events from realmId and 1 event from realmId2 should be expired now
|
// set time offset to the future. The remaining 2 events from realmId and 1 event from realmId2 should be expired now
|
||||||
setTimeOffset(150);
|
setTimeOffset(150);
|
||||||
testing().clearExpiredEvents();
|
testing().clearExpiredEvents();
|
||||||
Assert.assertEquals(0, testing().queryEvents(null, null, null, null, null, null, null, null, null).size());
|
Assert.assertEquals(0, testing().queryEvents(realmId, null, null, null, null, null, null, null, null).size());
|
||||||
|
Assert.assertEquals(0, testing().queryEvents(realmId2, null, null, null, null, null, null, null, null).size());
|
||||||
|
|
||||||
// Revert expirations
|
// Revert expirations
|
||||||
realm.setEventsExpiration(0);
|
realm.setEventsExpiration(0);
|
||||||
|
|
Loading…
Reference in a new issue