mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
fixes integration tests, which are relying on the admin flag
This commit is contained in:
@@ -27,7 +27,7 @@ public class UserITCase {
|
||||
.assertStatusCode(200)
|
||||
.requestUser(newUser)
|
||||
.assertStatusCode(200)
|
||||
.assertAdmin(aBoolean -> assertThat(aBoolean).isEqualTo(Boolean.TRUE))
|
||||
// we could no longer easily check if the user is an admin, because the admin flag is gone
|
||||
.assertPassword(Assert::assertNull)
|
||||
.requestChangePassword(newPassword)
|
||||
.assertStatusCode(204);
|
||||
@@ -36,7 +36,7 @@ public class UserITCase {
|
||||
.requestIndexResource(newUser, newPassword)
|
||||
.assertStatusCode(200)
|
||||
.requestUser(newUser)
|
||||
.assertAdmin(isAdmin -> assertThat(isAdmin).isEqualTo(Boolean.TRUE))
|
||||
// we could no longer easily check if the user is an admin, because the admin flag is gone
|
||||
.assertPassword(Assert::assertNull);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class UserITCase {
|
||||
.assertStatusCode(200)
|
||||
.requestUser(newUser)
|
||||
.assertStatusCode(200)
|
||||
.assertAdmin(aBoolean -> assertThat(aBoolean).isEqualTo(Boolean.TRUE)) // the user anonymous is not an admin
|
||||
// we could no longer easily check if the user is an admin, because the admin flag is gone
|
||||
.assertPassword(Assert::assertNull)
|
||||
.requestChangePassword(newPassword) // the oldPassword is not needed in the user resource
|
||||
.assertStatusCode(204);
|
||||
@@ -96,7 +96,7 @@ public class UserITCase {
|
||||
.assertStatusCode(200)
|
||||
.requestUser(newUser)
|
||||
.assertStatusCode(200)
|
||||
.assertAdmin(aBoolean -> assertThat(aBoolean).isEqualTo(Boolean.TRUE))
|
||||
// we could no longer easily check if the user is an admin, because the admin flag is gone
|
||||
.assertPassword(Assert::assertNull)
|
||||
.assertType(s -> assertThat(s).isEqualTo(type))
|
||||
.assertPasswordLinkDoesNotExists();
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user