use of org.graylog.grn.GRN in project graylog2-server by Graylog2.
the class DBGrantServiceTest method getForTargetExcludingGrantee.
@Test
@MongoDBFixtures("grants.json")
public void getForTargetExcludingGrantee() {
final GRN stream = grnRegistry.parse("grn::::stream:54e3deadbeefdeadbeef0001");
final GRN grantee = grnRegistry.parse("grn::::user:john");
assertThat(dbService.getForTargetExcludingGrantee(stream, grantee)).hasSize(2);
}
use of org.graylog.grn.GRN in project graylog2-server by Graylog2.
the class DBGrantServiceTest method getForGranteesOrGlobalWithCapability.
@Test
@MongoDBFixtures("grants.json")
public void getForGranteesOrGlobalWithCapability() {
final GRN jane = grnRegistry.newGRN("user", "jane");
final GRN john = grnRegistry.newGRN("user", "john");
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(jane), Capability.MANAGE)).hasSize(1);
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(jane), Capability.OWN)).hasSize(1);
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(john), Capability.VIEW)).hasSize(2);
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(jane, john), Capability.VIEW)).hasSize(3);
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(jane, john), Capability.MANAGE)).hasSize(1);
assertThat(dbService.getForGranteesOrGlobalWithCapability(ImmutableSet.of(jane, john), Capability.OWN)).hasSize(2);
}
use of org.graylog.grn.GRN in project graylog2-server by Graylog2.
the class DBGrantServiceTest method hasGrantFor.
@Test
@MongoDBFixtures("grants.json")
public void hasGrantFor() {
final GRN jane = grnRegistry.parse("grn::::user:jane");
final GRN dashboard1 = grnRegistry.parse("grn::::dashboard:54e3deadbeefdeadbeef0000");
final GRN stream1 = grnRegistry.parse("grn::::stream:54e3deadbeefdeadbeef0000");
final GRN stream2 = grnRegistry.parse("grn::::stream:54e3deadbeefdeadbeef0001");
assertThat(dbService.hasGrantFor(jane, Capability.VIEW, stream1)).isTrue();
assertThat(dbService.hasGrantFor(jane, Capability.MANAGE, stream2)).isTrue();
assertThat(dbService.hasGrantFor(jane, Capability.OWN, dashboard1)).isTrue();
assertThat(dbService.hasGrantFor(jane, Capability.MANAGE, stream1)).isFalse();
assertThat(dbService.hasGrantFor(jane, Capability.VIEW, dashboard1)).isFalse();
}
use of org.graylog.grn.GRN in project graylog2-server by Graylog2.
the class DBGrantServiceTest method getForGranteesOrGlobal.
@Test
@MongoDBFixtures("grants.json")
public void getForGranteesOrGlobal() {
final GRN jane = grnRegistry.newGRN("user", "jane");
final GRN john = grnRegistry.newGRN("user", "john");
assertThat(dbService.getForGranteesOrGlobal(Collections.singleton(jane))).hasSize(4);
assertThat(dbService.getForGranteesOrGlobal(Collections.singleton(john))).hasSize(3);
}
use of org.graylog.grn.GRN in project graylog2-server by Graylog2.
the class ViewSharingToGrantsMigrationTest method migrateAllOfInstanceShares.
@Test
@DisplayName("migrate all-of-instance shares")
void migrateAllOfInstanceShares() throws Exception {
final GRN everyone = GRNRegistry.GLOBAL_USER_GRN;
when(roleService.load(anyString())).thenThrow(new NotFoundException());
final GRN dashboard2 = GRNTypes.DASHBOARD.toGRN("54e3deadbeefdeadbeef0003");
assertThat(grantService.hasGrantFor(everyone, Capability.VIEW, dashboard2)).isFalse();
migration.upgrade();
assertThat(grantService.hasGrantFor(everyone, Capability.VIEW, dashboard2)).isTrue();
assertThat(grantService.hasGrantFor(everyone, Capability.OWN, dashboard2)).isFalse();
assertThat(grantService.hasGrantFor(everyone, Capability.MANAGE, dashboard2)).isFalse();
assertDeletedViewSharing("54e3deadbeefdeadbeef0003");
}
Aggregations