mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
fix autocomplete for user without admin permission + integration tests
This commit is contained in:
@@ -46,11 +46,11 @@ public class TestData {
|
||||
return DEFAULT_REPOSITORIES.get(repositoryType);
|
||||
}
|
||||
|
||||
public static void createUser(String username, String password) {
|
||||
createUser(username, password, false, "xml");
|
||||
public static void createNotAdminUser(String username, String password) {
|
||||
createUser(username, password, false, "xml", "user1@scm-manager.org");
|
||||
}
|
||||
|
||||
public static void createUser(String username, String password, boolean isAdmin, String type) {
|
||||
public static void createUser(String username, String password, boolean isAdmin, String type, final String email) {
|
||||
LOG.info("create user with username: {}", username);
|
||||
String admin = isAdmin ? "true" : "false";
|
||||
given(VndMediaType.USER)
|
||||
@@ -61,7 +61,7 @@ public class TestData {
|
||||
.append(" \"admin\": ").append(admin).append(",\n")
|
||||
.append(" \"creationDate\": \"2018-08-21T12:26:46.084Z\",\n")
|
||||
.append(" \"displayName\": \"").append(username).append("\",\n")
|
||||
.append(" \"mail\": \"user1@scm-manager.org\",\n")
|
||||
.append(" \"mail\": \"" + email + "\",\n")
|
||||
.append(" \"name\": \"").append(username).append("\",\n")
|
||||
.append(" \"password\": \"").append(password).append("\",\n")
|
||||
.append(" \"type\": \"").append(type).append("\"\n")
|
||||
@@ -71,6 +71,16 @@ public class TestData {
|
||||
.statusCode(HttpStatus.SC_CREATED)
|
||||
;
|
||||
}
|
||||
public static void createGroup(String groupName, String desc) {
|
||||
LOG.info("create group with group name: {} and description {}", groupName, desc);
|
||||
given(VndMediaType.GROUP)
|
||||
.when()
|
||||
.content(getGroupJson(groupName,desc))
|
||||
.post(getGroupsUrl())
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_CREATED)
|
||||
;
|
||||
}
|
||||
|
||||
public static void createUserPermission(String name, PermissionType permissionType, String repositoryType) {
|
||||
String defaultPermissionUrl = TestData.getDefaultPermissionUrl(USER_SCM_ADMIN, USER_SCM_ADMIN, repositoryType);
|
||||
@@ -199,21 +209,36 @@ public class TestData {
|
||||
.build().toString();
|
||||
}
|
||||
|
||||
public static String getGroupJson(String groupname , String desc) {
|
||||
return JSON_BUILDER
|
||||
.add("name", groupname)
|
||||
.add("description", desc)
|
||||
.build().toString();
|
||||
}
|
||||
|
||||
public static URI getMeUrl() {
|
||||
return RestUtil.createResourceUrl("me/");
|
||||
}
|
||||
|
||||
public static URI getGroupsUrl() {
|
||||
return RestUtil.createResourceUrl("groups/");
|
||||
}
|
||||
|
||||
public static URI getUsersUrl() {
|
||||
return RestUtil.createResourceUrl("users/");
|
||||
|
||||
}
|
||||
|
||||
public static URI getUserUrl(String username) {
|
||||
return getUsersUrl().resolve(username);
|
||||
|
||||
}
|
||||
|
||||
public static URI getUsersAutoCompleteUrl(String query ) {
|
||||
return RestUtil.createResourceUrl("autocomplete/users?q="+query);
|
||||
}
|
||||
|
||||
public static URI getGroupsAutoCompleteUrl(String query ) {
|
||||
return RestUtil.createResourceUrl("autocomplete/groups?q="+query);
|
||||
}
|
||||
|
||||
public static String createPasswordChangeJson(String oldPassword, String newPassword) {
|
||||
return JSON_BUILDER
|
||||
@@ -225,4 +250,5 @@ public class TestData {
|
||||
public static void main(String[] args) {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user