fixes integration tests, which are relying on the admin flag

This commit is contained in:
Sebastian Sdorra
2019-03-13 15:56:40 +01:00
parent 1627518954
commit 1179fd37fa
2 changed files with 24 additions and 6 deletions

View File

@@ -74,9 +74,27 @@ public class TestData {
.append(" }").toString())
.post(getUsersUrl())
.then()
.statusCode(HttpStatus.SC_CREATED)
;
.statusCode(HttpStatus.SC_CREATED);
if (isAdmin) {
assignAdminPermissions(username);
}
}
public static void assignAdminPermissions(String username) {
LOG.info("assign admin permissions to user {}", username);
given(VndMediaType.PERMISSION_COLLECTION)
.when()
.body("{'permissions': ['*']}".replaceAll("'", "\""))
.put(getPermissionUrl(username))
.then()
.statusCode(HttpStatus.SC_NO_CONTENT);
}
private static URI getPermissionUrl(String username) {
return RestUtil.createResourceUrl(String.format("users/%s/permissions", username));
}
public static void createGroup(String groupName, String desc) {
LOG.info("create group with group name: {} and description {}", groupName, desc);
given(VndMediaType.GROUP)