Search in sources :

Example 1 with DBGrantService

use of org.graylog.security.DBGrantService in project graylog2-server by Graylog2.

the class EntityDependencyResolverTest method setUp.

@BeforeEach
void setUp(@Mock ContentPackService contentPackService, GRNRegistry grnRegistry, @Mock GRNDescriptorService grnDescriptorService, MongoDBTestService mongodb, MongoJackObjectMapperProvider objectMapperProvider) {
    this.grnRegistry = grnRegistry;
    DBGrantService dbGrantService = new DBGrantService(mongodb.mongoConnection(), objectMapperProvider, this.grnRegistry);
    this.contentPackService = contentPackService;
    this.grnDescriptorService = grnDescriptorService;
    entityDependencyResolver = new EntityDependencyResolver(contentPackService, grnRegistry, grnDescriptorService, dbGrantService);
}
Also used : DBGrantService(org.graylog.security.DBGrantService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with DBGrantService

use of org.graylog.security.DBGrantService in project graylog2-server by Graylog2.

the class UserPermissionsToGrantsMigrationTest method setUp.

@BeforeEach
void setUp(MongoDBTestService mongodb, MongoJackObjectMapperProvider mongoJackObjectMapperProvider, GRNRegistry grnRegistry, TestUserService userService, @Mock ViewService viewService) {
    this.grnRegistry = grnRegistry;
    this.viewService = viewService;
    this.userSelfEditPermissionCount = new Permissions(ImmutableSet.of()).userSelfEditPermissions("dummy").size();
    dbGrantService = new DBGrantService(mongodb.mongoConnection(), mongoJackObjectMapperProvider, grnRegistry);
    this.userService = userService;
    DBGrantService dbGrantService = new DBGrantService(mongodb.mongoConnection(), mongoJackObjectMapperProvider, grnRegistry);
    migration = new UserPermissionsToGrantsMigration(userService, dbGrantService, grnRegistry, viewService, "admin");
}
Also used : Permissions(org.graylog2.shared.security.Permissions) DBGrantService(org.graylog.security.DBGrantService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DBGrantService

use of org.graylog.security.DBGrantService in project graylog2-server by Graylog2.

the class ViewSharingToGrantsMigrationTest method setUp.

@BeforeEach
void setUp(MongoDBTestService mongodb, MongoJackObjectMapperProvider objectMapperProvider, GRNRegistry grnRegistry, @Mock ClusterConfigService clusterConfigService, @Mock UserService userService, @Mock RoleService roleService) {
    this.dbCollection = mongodb.mongoCollection("view_sharings");
    this.userService = userService;
    this.roleService = roleService;
    this.grantService = new DBGrantService(mongodb.mongoConnection(), objectMapperProvider, grnRegistry);
    when(userService.load(anyString())).thenAnswer(a -> {
        final String argument = a.getArgument(0);
        return createUser(argument);
    });
    final EntityOwnershipService entityOwnershipService = new EntityOwnershipService(grantService, grnRegistry);
    final TestViewService viewService = new TestViewService(mongodb.mongoConnection(), objectMapperProvider, clusterConfigService, entityOwnershipService);
    this.migration = new ViewSharingToGrantsMigration(mongodb.mongoConnection(), grantService, userService, roleService, "admin", viewService, grnRegistry);
}
Also used : EntityOwnershipService(org.graylog.security.entities.EntityOwnershipService) DBGrantService(org.graylog.security.DBGrantService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DBGrantService

use of org.graylog.security.DBGrantService in project graylog2-server by Graylog2.

the class EntitySharesServiceTest method setUp.

@BeforeEach
void setUp(MongoDBTestService mongodb, MongoJackObjectMapperProvider mongoJackObjectMapperProvider, GRNRegistry grnRegistry) {
    this.grnRegistry = grnRegistry;
    dbGrantService = new DBGrantService(mongodb.mongoConnection(), mongoJackObjectMapperProvider, this.grnRegistry);
    lenient().when(entityDependencyResolver.resolve(any())).thenReturn(ImmutableSet.of());
    lenient().when(entityDependencyPermissionChecker.check(any(), any(), any())).thenReturn(ImmutableMultimap.of());
    lenient().when(granteeService.getAvailableGrantees(any())).thenReturn(ImmutableSet.of());
    final EventBus serverEventBus = mock(EventBus.class);
    this.entitySharesService = new EntitySharesService(dbGrantService, entityDependencyResolver, entityDependencyPermissionChecker, grnRegistry, granteeService, serverEventBus);
    // TODO this is needed to initialize the CAPABILITIES field
    new BuiltinCapabilities();
}
Also used : BuiltinCapabilities(org.graylog.security.BuiltinCapabilities) DBGrantService(org.graylog.security.DBGrantService) EventBus(com.google.common.eventbus.EventBus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DBGrantService

use of org.graylog.security.DBGrantService in project graylog2-server by Graylog2.

the class GranteeSharesServiceTest method setUp.

@BeforeEach
void setUp(MongoDBTestService mongodb, MongoJackObjectMapperProvider mongoJackObjectMapperProvider, GRNRegistry grnRegistry, @Mock GRNDescriptorService grnDescriptorService, @Mock GranteeService granteeService) {
    this.grnDescriptorService = grnDescriptorService;
    final DBGrantService dbGrantService = new DBGrantService(mongodb.mongoConnection(), mongoJackObjectMapperProvider, grnRegistry);
    when(granteeService.getGranteeAliases(any(GRN.class))).thenAnswer(a -> Collections.singleton(a.getArgument(0)));
    this.granteeSharesService = new GranteeSharesService(dbGrantService, grnDescriptorService, granteeService);
}
Also used : GRN(org.graylog.grn.GRN) DBGrantService(org.graylog.security.DBGrantService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DBGrantService (org.graylog.security.DBGrantService)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 EntityOwnershipService (org.graylog.security.entities.EntityOwnershipService)2 EventBus (com.google.common.eventbus.EventBus)1 GRN (org.graylog.grn.GRN)1 BuiltinCapabilities (org.graylog.security.BuiltinCapabilities)1 Permissions (org.graylog2.shared.security.Permissions)1 RoleServiceImpl (org.graylog2.users.RoleServiceImpl)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1