use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class DBGrantServiceTest method getForGranteeWithCapability.
@Test
@MongoDBFixtures("grants.json")
public void getForGranteeWithCapability() {
final GRN jane = grnRegistry.newGRN("user", "jane");
final GRN john = grnRegistry.newGRN("user", "john");
assertThat(dbService.getForGranteeWithCapability(jane, Capability.MANAGE)).hasSize(1);
assertThat(dbService.getForGranteeWithCapability(jane, Capability.OWN)).hasSize(1);
assertThat(dbService.getForGranteeWithCapability(john, Capability.VIEW)).hasSize(1);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class DBGrantServiceTest method ensure.
@Test
@MongoDBFixtures("grants.json")
public void ensure() {
final GRN jane = grnRegistry.parse("grn::::user:jane");
final GRN stream1 = grnRegistry.parse("grn::::stream:54e3deadbeefdeadbeef0000");
final GRN newStream = grnRegistry.parse("grn::::stream:54e3deadbeefdeadbeef0888");
// Matches existing grant. Returns original
final GrantDTO stream1Grant = dbService.getForTargetAndGrantee(stream1, jane).get(0);
GrantDTO result = dbService.ensure(jane, Capability.VIEW, stream1, "admin");
assertThat(result).isEqualTo(stream1Grant);
// Updates to a higher capability
result = dbService.ensure(jane, Capability.MANAGE, stream1, "admin");
assertThat(result.capability()).isEqualTo(Capability.MANAGE);
// Don't downgrade to a lower capability
result = dbService.ensure(jane, Capability.VIEW, stream1, "admin");
assertThat(result.capability()).isEqualTo(Capability.MANAGE);
// Create a new grant
assertThat(dbService.ensure(jane, Capability.MANAGE, newStream, "admin")).isNotNull();
assertThat(dbService.getForTarget(newStream)).satisfies(grantDTOS -> {
assertThat(grantDTOS.size()).isEqualTo(1);
assertThat(grantDTOS.get(0).grantee()).isEqualTo(jane);
assertThat(grantDTOS.get(0).capability()).isEqualTo(Capability.MANAGE);
assertThat(grantDTOS.get(0).target()).isEqualTo(newStream);
});
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class DBGrantServiceTest method getForGrantee.
@Test
@MongoDBFixtures("grants.json")
public void getForGrantee() {
final GRN jane = grnRegistry.newGRN("user", "jane");
final GRN john = grnRegistry.newGRN("user", "john");
assertThat(dbService.getForGrantee(jane)).hasSize(3);
assertThat(dbService.getForGrantee(john)).hasSize(2);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20200204122000_MigrateUntypedViewsToDashboardsTest method doesNotChangeTypedViews.
@Test
@MongoDBFixtures("V20200204122000_MigrateUntypedViewsToDashboardsTest/typed_views.json")
public void doesNotChangeTypedViews() throws Exception {
this.migration.upgrade();
final MigrationCompleted migrationCompleted = captureMigrationCompleted();
assertThat(migrationCompleted.viewIds()).isEmpty();
verify(this.viewsCollection, times(1)).find(any(Bson.class));
verify(this.viewsCollection, never()).updateOne(any(BasicDBObject.class), any(Document.class));
verify(this.searchesCollection, never()).updateOne(any(BasicDBObject.class), any(Document.class));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class EventDefinitionFacadeTest method listExcerpts.
@Test
@MongoDBFixtures("EventDefinitionFacadeTest.json")
public void listExcerpts() {
final Set<EntityExcerpt> excerpts = facade.listEntityExcerpts();
final EntityExcerpt excerpt = excerpts.iterator().next();
assertThat(excerpt.title()).isEqualTo("title");
assertThat(excerpt.id()).isEqualTo(ModelId.of("5d4032513d2746703d1467f6"));
assertThat(excerpt.type()).isEqualTo(ModelTypes.EVENT_DEFINITION_V1);
}
Aggregations