use of org.graylog2.security.PasswordAlgorithmFactory in project graylog2-server by Graylog2.
the class MigrationHelpersTest method newUser.
private User newUser(Permissions permissions) {
final BCryptPasswordAlgorithm passwordAlgorithm = new BCryptPasswordAlgorithm(10);
final PasswordAlgorithmFactory passwordAlgorithmFactory = new PasswordAlgorithmFactory(Collections.emptyMap(), passwordAlgorithm);
return new UserImpl(passwordAlgorithmFactory, permissions, ImmutableMap.of());
}
use of org.graylog2.security.PasswordAlgorithmFactory in project graylog2-server by Graylog2.
the class UserImplTest method getPermissionsReturnsListOfPermissions.
@Test
public void getPermissionsReturnsListOfPermissions() throws Exception {
final Permissions permissions = new Permissions(Collections.emptySet());
final List<String> customPermissions = Collections.singletonList("subject:action");
final Map<String, Object> fields = ImmutableMap.of(UserImpl.USERNAME, "foobar", UserImpl.PERMISSIONS, customPermissions);
user = new UserImpl(passwordAlgorithmFactory, permissions, fields);
assertThat(user.getPermissions()).containsAll(permissions.userSelfEditPermissions("foobar")).contains("subject:action");
}
use of org.graylog2.security.PasswordAlgorithmFactory in project graylog2-server by Graylog2.
the class UserImplTest method getPermissionsWorksWithEmptyPermissions.
@Test
public void getPermissionsWorksWithEmptyPermissions() throws Exception {
final Permissions permissions = new Permissions(Collections.emptySet());
final Map<String, Object> fields = Collections.singletonMap(UserImpl.USERNAME, "foobar");
user = new UserImpl(passwordAlgorithmFactory, permissions, fields);
assertThat(user.getPermissions()).containsAll(permissions.userSelfEditPermissions("foobar"));
}
use of org.graylog2.security.PasswordAlgorithmFactory in project graylog2-server by Graylog2.
the class UserImplTest method permissionsArentModified.
@Test
public void permissionsArentModified() {
final Permissions permissions = new Permissions(Collections.emptySet());
final Map<String, Object> fields = Collections.singletonMap(UserImpl.USERNAME, "foobar");
user = new UserImpl(passwordAlgorithmFactory, permissions, fields);
final List<String> newPermissions = ImmutableList.<String>builder().addAll(user.getPermissions()).add("perm:1").build();
user.setPermissions(newPermissions);
}
use of org.graylog2.security.PasswordAlgorithmFactory in project graylog2-server by Graylog2.
the class UserImplTest method getObjectPermissions.
@Test
public void getObjectPermissions() {
final Permissions permissions = new Permissions(Collections.emptySet());
final List<String> customPermissions = ImmutableList.of("subject:action", "*");
final Map<String, Object> fields = ImmutableMap.of(UserImpl.USERNAME, "foobar", UserImpl.PERMISSIONS, customPermissions);
user = new UserImpl(passwordAlgorithmFactory, permissions, fields);
final Set<Permission> userSelfEditPermissions = permissions.userSelfEditPermissions("foobar").stream().map(CaseSensitiveWildcardPermission::new).collect(Collectors.toSet());
assertThat(user.getObjectPermissions()).containsAll(userSelfEditPermissions).contains(new CaseSensitiveWildcardPermission("subject:action")).extracting("class").containsOnlyOnce(AllPermission.class);
}
Aggregations