mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
bug5230: Removed RoleDefinition.isTransitive() from selenium API Test
representation of RoleDefinition
This commit is contained in:
1 parent
22aa1e5aa6
commit
faaf511dfb
4 files changed
+25
-65
No files matched your search
+8
-20
@@ -21,33 +21,25 @@ public class RoleApi {
|
||||
private static final String KEY_ROLE_NAME = "roleName";
|
||||
private static final String KEY_PERMISSIONS = "permissions";
|
||||
private static final String KEY_ID = "roleId";
|
||||
private static final String KEY_TRANSITIVE = "transitive";
|
||||
|
||||
public Role getRole(ApiContext ctx, UUID roleId) {
|
||||
return new Role(ctx.get(ROLE_URL + roleId.toString()));
|
||||
public RoleDefinition getRole(ApiContext ctx, UUID roleId) {
|
||||
return new RoleDefinition(ctx.get(ROLE_URL + roleId.toString()));
|
||||
}
|
||||
|
||||
public Role createRole(ApiContext ctx, String roleName) {
|
||||
return createRole(ctx, roleName, /* transitive */ true);
|
||||
}
|
||||
|
||||
public Role createRole(ApiContext ctx, String roleName, boolean transitive) {
|
||||
public RoleDefinition createRole(ApiContext ctx, String roleName) {
|
||||
final Map<String, String> formParams = new HashMap<>();
|
||||
formParams.put(KEY_ROLE_NAME, roleName);
|
||||
final Map<String, String> queryParams = new HashMap<>();
|
||||
queryParams.put(KEY_TRANSITIVE, Boolean.toString(transitive));
|
||||
return new Role(ctx.post(ROLE_URL, queryParams, formParams));
|
||||
return new RoleDefinition(ctx.post(ROLE_URL, queryParams, formParams));
|
||||
}
|
||||
|
||||
public void deleteRole(ApiContext ctx, UUID roleId) {
|
||||
ctx.delete(ROLE_URL + roleId.toString());
|
||||
}
|
||||
|
||||
public String updateRole(ApiContext ctx, UUID roleId, Iterable<String> permissionStrings, String roleName,
|
||||
boolean transitive) {
|
||||
public String updateRole(ApiContext ctx, UUID roleId, Iterable<String> permissionStrings, String roleName) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put(KEY_ROLE_NAME, roleName);
|
||||
json.put(KEY_TRANSITIVE, transitive);
|
||||
final JSONArray permissionArray = new JSONArray();
|
||||
for (String permission : permissionStrings) {
|
||||
permissionArray.add(permission);
|
||||
@@ -56,9 +48,9 @@ public class RoleApi {
|
||||
return ctx.put(ROLE_URL + roleId.toString(), new HashMap<>(), json);
|
||||
}
|
||||
|
||||
public static class Role extends JsonWrapper {
|
||||
public static class RoleDefinition extends JsonWrapper {
|
||||
|
||||
public Role(JSONObject json) {
|
||||
public RoleDefinition(JSONObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
@@ -70,10 +62,6 @@ public class RoleApi {
|
||||
return UUID.fromString(get(KEY_ID));
|
||||
}
|
||||
|
||||
public boolean isTransitive() {
|
||||
return get(KEY_TRANSITIVE);
|
||||
}
|
||||
|
||||
public Iterable<String> getPermissions() {
|
||||
JSONArray array = get(KEY_PERMISSIONS);
|
||||
Collection<String> col = new ArrayList<>();
|
||||
@@ -107,7 +95,7 @@ public class RoleApi {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Role other = (Role) obj;
|
||||
RoleDefinition other = (RoleDefinition) obj;
|
||||
final String name = getName();
|
||||
final String otherName = other.getName();
|
||||
if (name == null) {
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ import org.json.simple.JSONObject;
|
||||
import com.sap.sailing.selenium.api.core.ApiContext;
|
||||
import com.sap.sailing.selenium.api.core.ApiRequest;
|
||||
import com.sap.sailing.selenium.api.core.JsonWrapper;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.Role;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.RoleDefinition;
|
||||
|
||||
public class UserGroupApi {
|
||||
|
||||
@@ -134,12 +134,12 @@ public class UserGroupApi {
|
||||
return col;
|
||||
}
|
||||
|
||||
public Iterable<Role> getRoles() {
|
||||
public Iterable<RoleDefinition> getRoles() {
|
||||
JSONArray array = get(KEY_ROLES);
|
||||
Collection<Role> col = new ArrayList<>();
|
||||
Collection<RoleDefinition> col = new ArrayList<>();
|
||||
if (array != null) {
|
||||
for (Object roleJson : array) {
|
||||
col.add(new Role((JSONObject) roleJson));
|
||||
col.add(new RoleDefinition((JSONObject) roleJson));
|
||||
}
|
||||
}
|
||||
return col;
|
||||
|
||||
+9
-37
@@ -3,7 +3,6 @@ package com.sap.sailing.selenium.api.test;
|
||||
import static com.sap.sailing.selenium.api.core.ApiContext.SECURITY_CONTEXT;
|
||||
import static com.sap.sailing.selenium.api.core.ApiContext.createAdminApiContext;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -17,7 +16,7 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.selenium.api.core.ApiContext;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.Role;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.RoleDefinition;
|
||||
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
@@ -35,13 +34,13 @@ public class RoleApiTest extends AbstractSeleniumTest {
|
||||
final ApiContext adminCtx = createAdminApiContext(getContextRoot(), SECURITY_CONTEXT);
|
||||
|
||||
final String testRoleName = "test role 123";
|
||||
final Role roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
final RoleDefinition roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
|
||||
assertEquals("Responded role name of createRole is different!", testRoleName, roleCreated.getName());
|
||||
assertNotNull("UUID cannot be null!", roleCreated.getId());
|
||||
assertTrue("Permissions should be empty!", Util.isEmpty(roleCreated.getPermissions()));
|
||||
|
||||
final Role roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
final RoleDefinition roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
|
||||
assertEquals("Responded role name of getRole is different!", roleCreated.getName(), roleGet.getName());
|
||||
assertEquals("UUID must be the same!", roleCreated.getId(), roleGet.getId());
|
||||
@@ -55,11 +54,11 @@ public class RoleApiTest extends AbstractSeleniumTest {
|
||||
final ApiContext adminCtx = createAdminApiContext(getContextRoot(), SECURITY_CONTEXT);
|
||||
|
||||
final String testRoleName = "test role 123";
|
||||
final Role roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
final RoleDefinition roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
|
||||
assertNotNull("UUID cannot be null!", roleCreated.getId());
|
||||
|
||||
final Role roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
final RoleDefinition roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
|
||||
assertEquals("UUID must be the same!", roleCreated.getId(), roleGet.getId());
|
||||
|
||||
@@ -78,11 +77,11 @@ public class RoleApiTest extends AbstractSeleniumTest {
|
||||
final ApiContext adminCtx = createAdminApiContext(getContextRoot(), SECURITY_CONTEXT);
|
||||
|
||||
final String testRoleName = "test role 123";
|
||||
final Role roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
final RoleDefinition roleCreated = roleApi.createRole(adminCtx, testRoleName);
|
||||
|
||||
assertNotNull("UUID cannot be null!", roleCreated.getId());
|
||||
|
||||
final Role roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
final RoleDefinition roleGet = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
|
||||
assertEquals("UUID must be the same!", roleCreated.getId(), roleGet.getId());
|
||||
|
||||
@@ -91,12 +90,11 @@ public class RoleApiTest extends AbstractSeleniumTest {
|
||||
permissions.add("BOAT:READ");
|
||||
|
||||
final String updatedRoleName = roleCreated.getName() + "_changed";
|
||||
final String roleUpdate = roleApi.updateRole(adminCtx, roleCreated.getId(), permissions, updatedRoleName,
|
||||
roleCreated.isTransitive());
|
||||
final String roleUpdate = roleApi.updateRole(adminCtx, roleCreated.getId(), permissions, updatedRoleName);
|
||||
|
||||
assertNull("Empty string expected.", roleUpdate);
|
||||
|
||||
final Role roleGetAfterUpdate = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
final RoleDefinition roleGetAfterUpdate = roleApi.getRole(adminCtx, roleCreated.getId());
|
||||
|
||||
assertEquals("Responded role name of getRole is different!", updatedRoleName, roleGetAfterUpdate.getName());
|
||||
assertEquals("UUID must be the same!", roleCreated.getId(), roleGetAfterUpdate.getId());
|
||||
@@ -110,32 +108,6 @@ public class RoleApiTest extends AbstractSeleniumTest {
|
||||
roleApi.deleteRole(adminCtx, roleCreated.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateRoleTransitive() {
|
||||
final ApiContext adminCtx = createAdminApiContext(getContextRoot(), SECURITY_CONTEXT);
|
||||
final String testRoleName1 = "test role transitive_1";
|
||||
final Role roleCreated1 = roleApi.createRole(adminCtx, testRoleName1);
|
||||
assertTrue("role1 should be transitive by default", roleCreated1.isTransitive());
|
||||
|
||||
final String testRoleName2 = "test role transitive_2";
|
||||
final Role roleCreated2 = roleApi.createRole(adminCtx, testRoleName2, /* transitive */ true);
|
||||
assertTrue("role2 should be transitive by parameter", roleCreated2.isTransitive());
|
||||
|
||||
final String testRoleName3 = "test role transitive_3";
|
||||
final Role roleCreated3 = roleApi.createRole(adminCtx, testRoleName3, /* transitive */ false);
|
||||
assertFalse("role3 should be not transitive by parameter", roleCreated3.isTransitive());
|
||||
|
||||
assertNull("updateRole shouldn't return something", roleApi.updateRole(adminCtx, roleCreated1.getId(),
|
||||
roleCreated1.getPermissions(), roleCreated1.getName(), false));
|
||||
final Role roleUpdated1 = roleApi.getRole(adminCtx, roleCreated1.getId());
|
||||
assertFalse("role1 should be non-transitive after update", roleUpdated1.isTransitive());
|
||||
|
||||
assertNull("updateRole shouldn't return something", roleApi.updateRole(adminCtx, roleCreated3.getId(),
|
||||
roleCreated3.getPermissions(), roleCreated3.getName(), true));
|
||||
final Role roleUpdated3 = roleApi.getRole(adminCtx, roleCreated3.getId());
|
||||
assertTrue("role3 should be transitive after update", roleUpdated3.isTransitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createRoleWithDuplicateNameShouldFailTest() {
|
||||
final String roleName = "DUPLICATE_CHECK_ROLE";
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import com.sap.sailing.selenium.api.core.HttpException;
|
||||
import com.sap.sailing.selenium.api.event.EventApi;
|
||||
import com.sap.sailing.selenium.api.event.EventApi.Event;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.Role;
|
||||
import com.sap.sailing.selenium.api.event.RoleApi.RoleDefinition;
|
||||
import com.sap.sailing.selenium.api.event.SecurityApi;
|
||||
import com.sap.sailing.selenium.api.event.UserGroupApi;
|
||||
import com.sap.sailing.selenium.api.event.UserGroupApi.UserGroup;
|
||||
@@ -102,8 +102,8 @@ public class UserGroupApiTest extends AbstractSeleniumTest {
|
||||
assertNotNull("GroupId is missing in reponse!", userGroupCreated.getGroupId());
|
||||
|
||||
// add new role to group with admin user
|
||||
final Role createdRole = roleApi.createRole(adminCtx, "My-Epic-Role");
|
||||
roleApi.updateRole(adminCtx, createdRole.getId(), Arrays.asList("*"), createdRole.getName(), createdRole.isTransitive());
|
||||
final RoleDefinition createdRole = roleApi.createRole(adminCtx, "My-Epic-Role");
|
||||
roleApi.updateRole(adminCtx, createdRole.getId(), Arrays.asList("*"), createdRole.getName());
|
||||
userGroupApi.addRoleToGroup(adminCtx, userGroupCreated.getGroupId(), createdRole.getId(), false);
|
||||
|
||||
try {
|
||||
@@ -286,7 +286,7 @@ public class UserGroupApiTest extends AbstractSeleniumTest {
|
||||
|
||||
// create test role
|
||||
final RoleApi roleApi = new RoleApi();
|
||||
final Role role = roleApi.createRole(adminCtx, "test-role-01");
|
||||
final RoleDefinition role = roleApi.createRole(adminCtx, "test-role-01");
|
||||
assertNotNull("RoleId is missing in response!", role.getId());
|
||||
|
||||
// add role to group
|
||||
|
||||
Reference in new issue
Block a user