diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js index ce9a9adcead3c1e622fa97028e8a9ebfb84c35bb..3227548c6e15bb92108b2b42a15a5b223885b726 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js @@ -102,6 +102,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.DataSetFileSearchCriteria = dtos.DataSetFileSearchCriteria; this.TagSearchCriteria = dtos.TagSearchCriteria; this.AuthorizationGroupSearchCriteria = dtos.AuthorizationGroupSearchCriteria; + this.RoleAssignmentSearchCriteria = dtos.RoleAssignmentSearchCriteria; this.DataStoreSearchCriteria = dtos.DataStoreSearchCriteria; this.PropertyTypeSearchCriteria = dtos.PropertyTypeSearchCriteria; this.PropertyAssignmentSearchCriteria = dtos.PropertyAssignmentSearchCriteria; @@ -217,6 +218,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.SearchExternalDmsOperation = dtos.SearchExternalDmsOperation; this.SearchTagsOperation = dtos.SearchTagsOperation; this.SearchAuthorizationGroupsOperation = dtos.SearchAuthorizationGroupsOperation; + this.SearchRoleAssignmentsOperation = dtos.SearchRoleAssignmentsOperation; this.SearchCustomASServicesOperation = dtos.SearchCustomASServicesOperation; this.SearchObjectKindModificationsOperation = dtos.SearchObjectKindModificationsOperation; this.SearchGloballyOperation = dtos.SearchGloballyOperation; @@ -873,6 +875,8 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp var fo = new dtos.RoleAssignmentFetchOptions(); fo.withProject(); fo.withSpace(); + fo.withUser(); + fo.withAuthorizationGroup(); return fo; }; diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js index 1b7d0ddf177466d04788d3ddce89b7c66845796e..7c9936d937d2bcd420bb2f2e428d32f8d0fd6e50 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js @@ -426,6 +426,9 @@ var sources = [ 'as/dto/roleassignment/get/GetRoleAssignmentsOperation', 'as/dto/roleassignment/get/GetRoleAssignmentsOperationResult', 'as/dto/roleassignment/id/IRoleAssignmentId', + 'as/dto/roleassignment/search/RoleAssignmentSearchCriteria', + 'as/dto/roleassignment/search/SearchRoleAssignmentsOperation', + 'as/dto/roleassignment/search/SearchRoleAssignmentsOperationResult', 'as/dto/roleassignment/Role', 'as/dto/roleassignment/RoleLevel', 'as/dto/roleassignment/RoleAssignment', diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js index b7149eca358b036e11fd96200666f8f267379af1..77937c97d069e5c5a41576d5d0980ade377c87c0 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js @@ -305,6 +305,10 @@ define([ 'jquery', 'openbis', 'test/common' ], function($, openbis, common) { return this._executeSearchOperation(new c.SearchAuthorizationGroupsOperation(criteria, fetchOptions)); } + this.searchRoleAssignments = function(criteria, fetchOptions) { + return this._executeSearchOperation(new c.SearchRoleAssignmentsOperation(criteria, fetchOptions)); + } + this.searchCustomASServices = function(criteria, fetchOptions) { return this._executeSearchOperation(new c.SearchCustomASServicesOperation(criteria, fetchOptions)); } diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js index c44ff3fa87bafdba33ce31e0383ae1afe7d0d825..bd0f0d43f56550b168a609831579af68914bf3da 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js @@ -1344,12 +1344,45 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' var users = group.getUsers(); c.assertEqual(users.length, 0, "# Users"); var roleAssignments = group.getRoleAssignments(); - c.assertEqual(roleAssignments[0].getRole(), "OBSERVER", "Role of 1. role assignment"); - c.assertEqual(roleAssignments[0].getSpace().getCode(), "TEST", "Space of 1. role assignment"); - c.assertEqual(roleAssignments[1].getRole(), "ADMIN", "Role of 2. role assignment"); - c.assertEqual(roleAssignments[1].getProject().getCode(), "TEST-PROJECT", "Project code of 2. role assignment"); - c.assertEqual(roleAssignments[1].getProject().getSpace().getCode(), "TEST", "Project space of 2. role assignment"); - c.assertEqual(roleAssignments.length, 2, "# Role assignments"); + var numberOfTestSpaceAssignments = 0; + var numberOfProjectAssignments = 0; + for (var i = 0; i < roleAssignments.length; i++) { + var ra = roleAssignments[i]; + if (ra.getSpace() && ra.getSpace().getCode() === "TEST") { + c.assertEqual(ra.getRole(), "OBSERVER", "Role of assignment for space TEST"); + numberOfTestSpaceAssignments++; + } + if (ra.getProject()) { + c.assertEqual(ra.getRole(), "ADMIN", "Role of assignment for project"); + c.assertEqual(ra.getProject().getCode(), "TEST-PROJECT", "Project code of assignment for project"); + c.assertEqual(ra.getProject().getSpace().getCode(), "TEST", "Project space of assignment for project"); + numberOfProjectAssignments++; + } + } + c.assertEqual(numberOfTestSpaceAssignments, 1, "Number of TEST space assignments"); + c.assertEqual(numberOfProjectAssignments, 1, "Number of project assignments"); + } + + testSearch(c, fSearch, fCheck); + }); + + QUnit.test("searchRoleAssignments()", function(assert) { + var c = new common(assert, openbis); + var code; + + var fSearch = function(facade) { + var criteria = new c.RoleAssignmentSearchCriteria(); + criteria.withSpace().withCode().thatEquals("TEST"); + criteria.withUser().withUserId().thatEquals("observer"); + return facade.searchRoleAssignments(criteria, c.createRoleAssignmentFetchOptions()); + } + + var fCheck = function(facade, assignments) { + c.assertEqual(assignments.length, 1, "# Role Assignments"); + var assignment = assignments[0]; + c.assertEqual(assignment.getRole(), "OBSERVER", "Role"); + c.assertEqual(assignment.getRoleLevel(), "SPACE", "Role level"); + c.assertEqual(assignment.getSpace().getCode(), "TEST", "Space"); } testSearch(c, fSearch, fCheck);