[ADF-3885]Change auth host path in cloud e2e tests (#4123)

This commit is contained in:
cristinaj
2019-01-10 13:42:23 +00:00
committed by Eugenio Romano
parent a19d2c99be
commit 968c65ff70
13 changed files with 72 additions and 37 deletions
+24 -2
View File
@@ -21,12 +21,16 @@ import TestConfig = require('../../test.config');
export class ApiService {
HOST_SSO = TestConfig.adf.hostSso;
HOST_BPM = TestConfig.adf.hostBPM;
HOST_IDENTITY = TestConfig.adf.hostIdentity;
apiService = new AlfrescoApi({
provider: 'BPM',
bpmHost: `${this.HOST_BPM}`,
identityHost: `${this.HOST_IDENTITY}`,
authType: 'OAUTH',
oauth2: {
host: `${this.HOST_SSO}/auth/realms/springboot`,
host: `${this.HOST_SSO}`,
authType: '/protocol/openid-connect/token',
clientId: 'activiti',
scope: 'openid',
@@ -44,7 +48,25 @@ export class ApiService {
}
async performBpmOperation(path, method, queryParams, postBody) {
const uri = this.HOST_SSO + path;
const uri = this.HOST_BPM + path;
const pathParams = {}, formParams = {};
const authNames = [];
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
'Authorization': 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.bpmClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, {})
.catch((error) => {
throw (error);
});
}
async performIdentityOperation(path, method, queryParams, postBody) {
const uri = this.HOST_IDENTITY + path;
const pathParams = {}, formParams = {};
const authNames = [];
const contentTypes = ['application/json'];
+12 -12
View File
@@ -42,7 +42,7 @@ export class Identity {
}
async createUser(username) {
const path = '/auth/admin/realms/springboot/users';
const path = '/users';
const method = 'POST';
const queryParams = {}, postBody = {
'username': username,
@@ -51,55 +51,55 @@ export class Identity {
'enabled': true,
'email': username + '@alfresco.com'
};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async deleteUser(userId) {
const path = `/auth/admin/realms/springboot/users/${userId}`;
const path = `/users/${userId}`;
const method = 'DELETE';
const queryParams = {}, postBody = {
};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async getUserInfoByUsername(username) {
const path = `/auth/admin/realms/springboot/users`;
const path = `/users`;
const method = 'GET';
const queryParams = { 'username' : username }, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async resetPassword(id, password) {
const path = `/auth/admin/realms/springboot/users/${id}/reset-password`;
const path = `/users/${id}/reset-password`;
const method = 'PUT';
const queryParams = {},
postBody = {'type': 'password', 'value': password, 'temporary': false};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async getRoleByName(roleName) {
const path = `/auth/admin/realms/springboot/roles/${roleName}`;
const path = `/roles/${roleName}`;
const method = 'GET';
const queryParams = {},
postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async assignRole(userId, roleId, roleName) {
const path = `/auth/admin/realms/springboot/users/${userId}/role-mappings/realm`;
const path = `/users/${userId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {},
postBody = [{'id': roleId, 'name': roleName}];
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}