From 9e396c20cdb462bbc94a2722351b812fedce2025 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 29 Nov 2017 13:24:34 +0000 Subject: [PATCH] SSDM-5721: JS tests for updating persons SVN: 38988 --- .../openbis-v3-api-test/html/test/common.js | 2 + .../openbis-v3-api-test/html/test/dtos.js | 3 + .../html/test/openbis-execute-operations.js | 4 ++ .../html/test/test-update.js | 58 +++++++++++++++++++ 4 files changed, 67 insertions(+) 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 93eb1884087..80df931da45 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 @@ -56,6 +56,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.ExternalDmsUpdate = dtos.ExternalDmsUpdate; this.TagUpdate = dtos.TagUpdate; this.AuthorizationGroupUpdate = dtos.AuthorizationGroupUpdate; + this.PersonUpdate = dtos.PersonUpdate; this.SpaceDeletionOptions = dtos.SpaceDeletionOptions; this.ProjectDeletionOptions = dtos.ProjectDeletionOptions; this.ExperimentDeletionOptions = dtos.ExperimentDeletionOptions; @@ -196,6 +197,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.UpdateExternalDmsOperation = dtos.UpdateExternalDmsOperation; this.UpdateTagsOperation = dtos.UpdateTagsOperation; this.UpdateAuthorizationGroupsOperation = dtos.UpdateAuthorizationGroupsOperation; + this.UpdatePersonsOperation = dtos.UpdatePersonsOperation; this.UpdateOperationExecutionsOperation = dtos.UpdateOperationExecutionsOperation; this.UpdateSemanticAnnotationsOperation = dtos.UpdateSemanticAnnotationsOperation; 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 292cd2d2567..5ce29c77534 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 @@ -385,6 +385,9 @@ var sources = [ 'as/dto/person/search/UserIdsSearchCriteria', 'as/dto/person/search/SearchPersonsOperation', 'as/dto/person/search/SearchPersonsOperationResult', + 'as/dto/person/update/PersonUpdate', + 'as/dto/person/update/UpdatePersonsOperation', + 'as/dto/person/update/UpdatePersonsOperationResult', 'as/dto/person/Person', 'as/dto/project/create/ProjectCreation', 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 7be7b42a82f..329f9d96061 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 @@ -193,6 +193,10 @@ define([ 'jquery', 'openbis', 'test/common' ], function($, openbis, common) { return this._executeUpdateOperation(new c.UpdateAuthorizationGroupsOperation(updates)); } + this.updatePersons = function(updates) { + return this._executeUpdateOperation(new c.UpdatePersonsOperation(updates)); + } + this.updateOperationExecutions = function(updates) { return this._executeUpdateOperation(new c.UpdateOperationExecutionsOperation(updates)); } diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js index 36cce824f71..d711db51e35 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js @@ -554,6 +554,64 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testUpdate(c, fCreate, fUpdate, c.findAuthorizationGroup, fCheck); }); + QUnit.test("updatePersons()", function(assert) { + var c = new common(assert, openbis); + var userId = c.generateId("USER"); + + var fCreate = function(facade) { + var creation = new c.PersonCreation(); + creation.setUserId(userId); + return facade.createPersons([ creation ]).then(function(permIds) { + var creation = new c.RoleAssignmentCreation(); + creation.setUserId(permIds[0]); + creation.setRole(c.Role.ADMIN); + return facade.createRoleAssignments([ creation ]).then(function(assignmentId) { + return permIds; + }); + }); + } + + var fUpdate = function(facade, permId) { + var update = new c.PersonUpdate(); + update.setPersonId(permId); + update.setHomeSpaceId(new c.SpacePermId("TEST")) + return facade.updatePersons([ update ]); + } + + var fCheck = function(person) { + c.assertEqual(person.getUserId(), userId, "User id"); + c.assertEqual(person.getSpace().getCode(), "TEST", "Home space"); + c.assertEqual(person.isActive(), true, "Active"); + } + + testUpdate(c, fCreate, fUpdate, c.findPerson, fCheck); + }); + + QUnit.test("updatePersons() deactivate", function(assert) { + var c = new common(assert, openbis); + var userId = c.generateId("USER"); + + var fCreate = function(facade) { + var creation = new c.PersonCreation(); + creation.setUserId(userId); + return facade.createPersons([ creation ]); + } + + var fUpdate = function(facade, permId) { + var update = new c.PersonUpdate(); + update.setPersonId(permId); + update.deactivate(); + return facade.updatePersons([ update ]); + } + + var fCheck = function(person) { + c.assertEqual(person.getUserId(), userId, "User id"); + c.assertEqual(person.isActive(), false, "Active"); + } + + testUpdate(c, fCreate, fUpdate, c.findPerson, fCheck); + }); + QUnit.test("updateOperationExecutions()", function(assert) { var c = new common(assert, openbis); var permId = null; -- GitLab