[ADF-3962] sso download directive automated (#4452)

* sso download directive automated

* temp changes

* temp changes

* moving of services under lib testing and ADF-3962 automated

* removed the browser sleep

* cspell and linting fixes.

* codacy improvements

* export public-api update

* remove circular dep

* remove circular dep

* fixes

* fix user info test

* fix datatable

* random commit

* move other string

* fix lint

* fix lint

* fix prolem type

* fix failing test

* fix tag test

* fix problems after rebase

* fix lint

* remove space

* remove visibility method duplicated
This commit is contained in:
gmandakini
2019-03-27 09:57:26 +00:00
committed by Eugenio Romano
parent 89f612bbb0
commit 4376d357ac
191 changed files with 2664 additions and 2299 deletions
-91
View File
@@ -1,91 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
import TestConfig = require('../../test.config');
import { AlfrescoApiConfig } from '@alfresco/js-api/src/alfrescoApiConfig';
export class ApiService {
HOST_SSO: string = TestConfig.adf.hostSso;
HOST_BPM: string = TestConfig.adf.hostBPM;
HOST_IDENTITY: string = TestConfig.adf.hostIdentity;
config: AlfrescoApiConfig = {
provider: 'BPM',
hostBpm: this.HOST_BPM,
authType: 'OAUTH',
oauth2: {
host: this.HOST_SSO,
clientId: 'activiti',
scope: 'openid',
secret: '',
implicitFlow: false,
silentLogin: false,
redirectUri: '/',
redirectUriLogout: '/logout'
}
};
apiService: any;
constructor(clientId: string = 'activiti') {
this.config.oauth2.clientId = clientId;
this.apiService = new AlfrescoApi(this.config);
}
async login(username, password) {
await this.apiService.login(username, password);
}
async performBpmOperation(path, method, queryParams, postBody) {
const uri = this.HOST_BPM + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
'Authorization': 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.catch((error) => {
throw (error);
});
}
async performIdentityOperation(path, method, queryParams, postBody) {
const uri = this.HOST_IDENTITY + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
'Authorization': 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.catch((error) => {
throw (error);
});
}
}
-77
View File
@@ -1,77 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from '../APS-cloud/apiservice';
import { Util } from '../../util/util';
export class GroupIdentity {
api: ApiService = new ApiService();
async init(username, password) {
await this.api.login(username, password);
}
async createIdentityGroup(groupName = Util.generateRandomString(5)) {
await this.createGroup(groupName);
const group = await this.getGroupInfoByGroupName(groupName);
return group;
}
async deleteIdentityGroup(groupId) {
await this.deleteGroup(groupId);
}
async createGroup(groupName) {
const path = '/groups';
const method = 'POST';
const queryParams = {}, postBody = {
'name': groupName + 'TestGroup'
};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async deleteGroup(groupId) {
const path = `/groups/${groupId}`;
const method = 'DELETE';
const queryParams = {}, postBody = {
};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async getGroupInfoByGroupName(groupName) {
const path = `/groups`;
const method = 'GET';
const queryParams = { 'search' : groupName }, postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data[0];
}
async assignRole(groupId, roleId, roleName) {
const path = `/groups/${groupId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {},
postBody = [{'id': roleId, 'name': roleName}];
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
}
-93
View File
@@ -1,93 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from '../APS-cloud/apiservice';
import { Util } from '../../util/util';
export class Identity {
api: ApiService;
async init(username: string, password: string, clientId?: string) {
this.api = new ApiService(clientId);
await this.api.login(username, password);
}
async createIdentityUser(username = Util.generateRandomString(5), password = Util.generateRandomString(5)) {
await this.createUser(username);
const user = await this.getUserInfoByUsername(username);
await this.resetPassword(user.id, password);
user.password = password;
return user;
}
async deleteIdentityUser(userId) {
await this.deleteUser(userId);
}
async createUser(username) {
const path = '/users';
const method = 'POST';
const queryParams = {}, postBody = {
'username': username,
'firstName': username,
'lastName': 'LastName',
'enabled': true,
'email': username + '@alfresco.com'
};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async deleteUser(userId) {
const path = `/users/${userId}`;
const method = 'DELETE';
const queryParams = {}, postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async getUserInfoByUsername(username) {
const path = `/users`;
const method = 'GET';
const queryParams = { 'username': username }, postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data[0];
}
async resetPassword(id, password) {
const path = `/users/${id}/reset-password`;
const method = 'PUT';
const queryParams = {},
postBody = { 'type': 'password', 'value': password, 'temporary': false };
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async assignRole(userId, roleId, roleName) {
const path = `/users/${userId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {},
postBody = [{ 'id': roleId, 'name': roleName }];
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
}
@@ -1,40 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from './apiservice';
export class ProcessDefinitions {
api: ApiService = new ApiService();
constructor() {
}
async init(username, password) {
await this.api.login(username, password);
}
async getProcessDefinitions(appName) {
const path = '/' + appName + '-rb/v1/process-definitions';
const method = 'GET';
const queryParams = {};
const data = await this.api.performBpmOperation(path, method, queryParams, {});
return data;
}
}
@@ -1,74 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from './apiservice';
export class ProcessInstances {
api: ApiService = new ApiService();
constructor() {
}
async init(username, password) {
await this.api.login(username, password);
}
async createProcessInstance(processDefKey, appName, options?) {
const path = '/' + appName + '-rb/v1/process-instances';
const method = 'POST';
const queryParams = {}, postBody = {
'processDefinitionKey': processDefKey,
'payloadType': 'StartProcessPayload',
...options
};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async suspendProcessInstance(processInstanceId, appName) {
const path = '/' + appName + '-rb/v1/process-instances/' + processInstanceId + '/suspend';
const method = 'POST';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async deleteProcessInstance(processInstanceId, appName) {
const path = '/' + appName + '-rb/v1/process-instances/' + processInstanceId;
const method = 'DELETE';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async completeProcessInstance(processInstanceId, appName) {
const path = '/' + appName + '-rb/v1/process-instances/' + processInstanceId + '/complete';
const method = 'POST';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
}
-51
View File
@@ -1,51 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from './apiservice';
export class Query {
api: ApiService = new ApiService();
constructor() {
}
async init(username, password) {
await this.api.login(username, password);
}
async getProcessInstanceTasks(processInstanceId, appName) {
const path = '/' + appName + '-query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async getProcessInstanceSubProcesses(processInstanceId, appName) {
const path = '/' + appName + '-query/v1/process-instances/' + processInstanceId + '/subprocesses';
const method = 'GET';
const queryParams = {};
const data = await this.api.performBpmOperation(path, method, queryParams, {});
return data;
}
}
-43
View File
@@ -1,43 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from '../APS-cloud/apiservice';
export class Roles {
api: ApiService = new ApiService();
async init(username, password) {
await this.api.login(username, password);
}
async getRoleIdByRoleName(roleName) {
const path = `/roles`;
const method = 'GET';
let roleId;
const queryParams = {}, postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
for (const key in data) {
if (data[key].name === roleName) {
roleId = data[key].id;
}
}
return roleId;
}
}
-102
View File
@@ -1,102 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from './apiservice';
export class Tasks {
api: ApiService = new ApiService();
constructor() {
}
async init(username, password) {
await this.api.login(username, password);
}
async createStandaloneTask(taskName, appName, options?) {
const path = '/' + appName + '-rb/v1/tasks';
const method = 'POST';
const queryParams = {}, postBody = {
'name': taskName,
'payloadType': 'CreateTaskPayload',
...options
};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async completeTask(taskId, appName) {
const path = '/' + appName + '-rb/v1/tasks/' + taskId + '/complete';
const method = 'POST';
const queryParams = {}, postBody = {'payloadType': 'CompleteTaskPayload'};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async claimTask(taskId, appName) {
const path = '/' + appName + '-rb/v1/tasks/' + taskId + '/claim';
const method = 'POST';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async deleteTask(taskId, appName) {
const path = '/' + appName + '-rb/v1/tasks/' + taskId;
const method = 'DELETE';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async createAndCompleteTask (taskName, appName) {
const task = await this.createStandaloneTask(taskName, appName);
await this.claimTask(task.entry.id, appName);
await this.completeTask(task.entry.id, appName);
return task;
}
async getTask(taskId, appName) {
const path = '/' + appName + '-query/v1/tasks/' + taskId;
const method = 'GET';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
async createStandaloneSubtask(parentTaskId, appName, name) {
const path = '/' + appName + '-rb/v1/tasks';
const method = 'POST';
const queryParams = {}, postBody = {'name': name, 'parentTaskId': parentTaskId, 'payloadType': 'CreateTaskPayload'};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data;
}
}