use of org.graylog2.users.RoleService 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.users.RoleService 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");
}
Aggregations