use of org.graylog2.database.MongoConnection in project graylog2-server by Graylog2.
the class UserServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
this.mongoConnection = mongoRule.getMongoConnection();
this.configuration = new Configuration();
this.userFactory = new UserImplFactory(configuration);
this.permissions = new Permissions(ImmutableSet.of(new RestPermissions()));
this.userService = new UserServiceImpl(mongoConnection, configuration, roleService, userFactory, permissionsResolver);
when(roleService.getAdminRoleObjectId()).thenReturn("deadbeef");
}
use of org.graylog2.database.MongoConnection in project graylog2-server by Graylog2.
the class UserServiceImplTest method testGetPermissionsForUser.
@Test
public void testGetPermissionsForUser() throws Exception {
final InMemoryRolePermissionResolver permissionResolver = mock(InMemoryRolePermissionResolver.class);
final UserService userService = new UserServiceImpl(mongoConnection, configuration, roleService, userFactory, permissionResolver);
final UserImplFactory factory = new UserImplFactory(new Configuration());
final UserImpl user = factory.create(new HashMap<>());
user.setName("user");
final Role role = createRole("Foo");
user.setRoleIds(Collections.singleton(role.getId()));
user.setPermissions(Collections.singletonList("hello:world"));
when(permissionResolver.resolveStringPermission(role.getId())).thenReturn(Collections.singleton("foo:bar"));
assertThat(userService.getPermissionsForUser(user)).containsOnly("users:passwordchange:user", "users:edit:user", "foo:bar", "hello:world");
}
use of org.graylog2.database.MongoConnection in project graylog2-server by Graylog2.
the class V20161125161400_AlertReceiversMigrationTest method setUp.
@Before
public void setUp() throws Exception {
final MongoConnection mongoConnection = mock(MongoConnection.class);
final DB database = mock(DB.class);
when(mongoConnection.getDatabase()).thenReturn(database);
when(database.getCollection(eq("streams"))).thenReturn(dbCollection);
this.alertReceiversMigration = new V20161125161400_AlertReceiversMigration(clusterConfigService, streamService, alarmCallbackConfigurationService, mongoConnection);
}
use of org.graylog2.database.MongoConnection in project graylog2-server by Graylog2.
the class V20170110150100_FixAlertConditionsMigrationTest method setUp.
@Before
public void setUp() throws Exception {
this.clusterConfigService = spy(new ClusterConfigServiceImpl(objectMapperProvider, fongoRule.getConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), new ClusterEventBus()));
final MongoConnection mongoConnection = spy(fongoRule.getConnection());
final MongoDatabase mongoDatabase = spy(fongoRule.getDatabase());
when(mongoConnection.getMongoDatabase()).thenReturn(mongoDatabase);
this.collection = spy(mongoDatabase.getCollection("streams"));
when(mongoDatabase.getCollection("streams")).thenReturn(collection);
this.migration = new V20170110150100_FixAlertConditionsMigration(mongoConnection, clusterConfigService);
}
Aggregations