@alfresco/adf-testing
Version:
Alfresco ADF testing page and utils
1,189 lines (1,148 loc) • 513 kB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
ACTIVITI_CLOUD_APPS: () => (/* reexport */ ACTIVITI_CLOUD_APPS),
ApiService: () => (/* reexport */ ApiService),
ApiUtil: () => (/* reexport */ ApiUtil),
AppListCloudPage: () => (/* reexport */ AppListCloudPage),
AppPublish: () => (/* reexport */ AppPublish),
Application: () => (/* reexport */ Application),
ApplicationsUtil: () => (/* reexport */ ApplicationsUtil),
ArrayUtil: () => (/* reexport */ ArrayUtil),
BreadcrumbDropdownPage: () => (/* reexport */ BreadcrumbDropdownPage),
BreadcrumbPage: () => (/* reexport */ BreadcrumbPage),
BrowserActions: () => (/* reexport */ BrowserActions),
BrowserVisibility: () => (/* reexport */ BrowserVisibility),
CardBooleanItemPage: () => (/* reexport */ CardBooleanItemPage),
CardDateItemPage: () => (/* reexport */ CardDateItemPage),
CardSelectItemPage: () => (/* reexport */ CardSelectItemPage),
CardTextItemPage: () => (/* reexport */ CardTextItemPage),
CheckboxPage: () => (/* reexport */ CheckboxPage),
Column: () => (/* reexport */ Column),
ContentNodeSelectorDialogPage: () => (/* reexport */ ContentNodeSelectorDialogPage),
ContextMenuPage: () => (/* reexport */ ContextMenuPage),
DataTableBuilder: () => (/* reexport */ DataTableBuilder),
DataTableColumnSelector: () => (/* reexport */ DataTableColumnSelector),
DataTableComponentPage: () => (/* reexport */ DataTableComponentPage),
DataTableItem: () => (/* reexport */ DataTableItem),
DatePickerCalendarPage: () => (/* reexport */ DatePickerCalendarPage),
DatePickerPage: () => (/* reexport */ DatePickerPage),
DateTimePickerCalendarPage: () => (/* reexport */ DateTimePickerCalendarPage),
DateTimePickerPage: () => (/* reexport */ DateTimePickerPage),
Descriptor: () => (/* reexport */ Descriptor),
DocumentListPage: () => (/* reexport */ DocumentListPage),
DropActions: () => (/* reexport */ DropActions),
DropdownPage: () => (/* reexport */ DropdownPage),
E2eRequestApiHelper: () => (/* reexport */ E2eRequestApiHelper),
EditJsonDialog: () => (/* reexport */ EditJsonDialog),
EditProcessFilterCloudComponentPage: () => (/* reexport */ EditProcessFilterCloudComponentPage),
EditProcessFilterDialogPage: () => (/* reexport */ EditProcessFilterDialogPage),
EditTaskFilterCloudComponentPage: () => (/* reexport */ EditTaskFilterCloudComponentPage),
EditTaskFilterDialogPage: () => (/* reexport */ EditTaskFilterDialogPage),
FileBrowserUtil: () => (/* reexport */ FileBrowserUtil),
FileModel: () => (/* reexport */ FileModel),
FiltersPage: () => (/* reexport */ FiltersPage),
FormCloudService: () => (/* reexport */ FormCloudService),
FormFields: () => (/* reexport */ FormFields),
FormPage: () => (/* reexport */ FormPage),
FormUtil: () => (/* reexport */ FormUtil),
GenericLogger: () => (/* reexport */ GenericLogger),
GroupCloudComponentPage: () => (/* reexport */ GroupCloudComponentPage),
GroupIdentityService: () => (/* reexport */ GroupIdentityService),
HeaderPage: () => (/* reexport */ HeaderPage),
IdentityService: () => (/* reexport */ IdentityService),
IntegrationService: () => (/* reexport */ IntegrationService),
LocalStorageUtil: () => (/* reexport */ LocalStorageUtil),
LogLevelsEnum: () => (/* reexport */ LogLevelsEnum),
Logger: () => (/* reexport */ Logger),
LoginPage: () => (/* reexport */ LoginPage),
LoginSSOPage: () => (/* reexport */ LoginPage),
MessageEventsService: () => (/* reexport */ MessageEventsService),
ModelActions: () => (/* reexport */ ModelActions),
ModelsActions: () => (/* reexport */ ModelsActions),
PaginationPage: () => (/* reexport */ PaginationPage),
PeopleCloudComponentPage: () => (/* reexport */ PeopleCloudComponentPage),
ProcessCloudWidgetPage: () => (/* reexport */ ProcessCloudWidgetPage),
ProcessDefinitionsService: () => (/* reexport */ ProcessDefinitionsService),
ProcessFiltersCloudComponentPage: () => (/* reexport */ ProcessFiltersCloudComponentPage),
ProcessHeaderCloudPage: () => (/* reexport */ ProcessHeaderCloudPage),
ProcessInstanceHeaderPage: () => (/* reexport */ ProcessInstanceHeaderPage),
ProcessInstancesService: () => (/* reexport */ ProcessInstancesService),
ProcessListCloudComponentPage: () => (/* reexport */ ProcessListCloudComponentPage),
ProcessListPage: () => (/* reexport */ ProcessListPage),
ProcessServices: () => (/* reexport */ ProcessServices),
ProcessUtil: () => (/* reexport */ ProcessUtil),
Project: () => (/* reexport */ Project),
QueryService: () => (/* reexport */ QueryService),
RolesService: () => (/* reexport */ RolesService),
SearchService: () => (/* reexport */ SearchService),
SnackbarPage: () => (/* reexport */ SnackbarPage),
StartFormPage: () => (/* reexport */ StartFormPage),
StartProcessCloudPage: () => (/* reexport */ StartProcessCloudPage),
StartProcessPage: () => (/* reexport */ StartProcessPage),
StartTasksCloudPage: () => (/* reexport */ StartTasksCloudPage),
StringUtil: () => (/* reexport */ StringUtil),
TabsPage: () => (/* reexport */ TabsPage),
TaskActionsUtil: () => (/* reexport */ TaskActionsUtil),
TaskFiltersCloudComponentPage: () => (/* reexport */ TaskFiltersCloudComponentPage),
TaskFiltersPage: () => (/* reexport */ TaskFiltersPage),
TaskFormCloudComponent: () => (/* reexport */ TaskFormCloudComponent),
TaskFormPage: () => (/* reexport */ TaskFormPage),
TaskHeaderCloudPage: () => (/* reexport */ TaskHeaderCloudPage),
TaskListCloudComponentPage: () => (/* reexport */ TaskListCloudComponentPage),
TaskUtil: () => (/* reexport */ TaskUtil),
TasksService: () => (/* reexport */ TasksService),
Tenant: () => (/* reexport */ Tenant),
TestElement: () => (/* reexport */ TestElement),
TogglePage: () => (/* reexport */ TogglePage),
UploadActions: () => (/* reexport */ UploadActions),
UserFiltersUtil: () => (/* reexport */ UserFiltersUtil),
UserInfoPage: () => (/* reexport */ UserInfoPage),
UserModel: () => (/* reexport */ UserModel),
UsersActions: () => (/* reexport */ UsersActions),
ViewerPage: () => (/* reexport */ ViewerPage),
WaitActions: () => (/* reexport */ WaitActions),
Widget: () => (/* reexport */ Widget),
byCss: () => (/* reexport */ byCss),
createApiService: () => (/* reexport */ createApiService),
errorColor: () => (/* reexport */ errorColor),
infoColor: () => (/* reexport */ infoColor),
logColor: () => (/* reexport */ logColor),
logLevels: () => (/* reexport */ logLevels),
materialLocators: () => (/* reexport */ materialLocators),
warnColor: () => (/* reexport */ warnColor)
});
;// CONCATENATED MODULE: ./src/lib/shared/utils/string.util.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class StringUtil {
static generatePasswordString(length = 8) {
let text = '';
const lowerCaseLimit = Math.floor(length / 2);
text += StringUtil.generateRandomCharset(lowerCaseLimit, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
text += StringUtil.generateRandomCharset(length - lowerCaseLimit, 'abcdefghijklmnopqrstuvwxyz');
return text;
}
/**
* Generates a random string.
*
* @param length If this parameter is not provided the length is set to 8 by default.
* @returns random string
*/
static generateRandomString(length = 8) {
return StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
}
/**
* Generates a random lowercase string.
*
* @param length If this parameter is not provided the length is set to 8 by default.
* @returns random string
*/
static generateRandomLowercaseString(length = 8) {
return StringUtil.generateRandomCharset(length, 'abcdefghijklmnopqrstuvwxyz0123456789');
}
/**
* Generates a random email address following the format: abcdef@activiti.test.com
*
* @param domain email domain
* @param length email length
* @returns email address
*/
static generateRandomEmail(domain, length = 5) {
let email = StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
email += domain;
return email.toLowerCase();
}
/**
* Generates a random string - digits only.
*
* @param length If this parameter is not provided the length is set to 8 by default.
* @returns random string
*/
static generateRandomStringDigits(length = 8) {
return StringUtil.generateRandomCharset(length, '0123456789');
}
/**
* Generates a random string - non-latin characters only.
*
* @param length If this parameter is not provided the length is set to 3 by default.
* @returns random string
*/
static generateRandomStringNonLatin(length = 3) {
return StringUtil.generateRandomCharset(length, '密码你好𠮷');
}
/**
* Generates a random string.
*
* @param length If this parameter is not provided the length is set to 8 by default.
* @param charSet to use
* @returns random string
*/
static generateRandomCharset(length = 8, charSet) {
let text = '';
for (let i = 0; i < length; i++) {
text += charSet.charAt(Math.floor(Math.random() * charSet.length));
}
return text;
}
/**
* Generates a sequence of files with name: baseName + index + extension (e.g.) baseName1.txt, baseName2.txt, ...
*
* @param startIndex start index
* @param endIndex end index
* @param baseName the base name of all files
* @param extension the extension of the file
* @returns list of file names
*/
static generateFilesNames(startIndex, endIndex, baseName, extension) {
const fileNames = [];
for (let i = startIndex; i <= endIndex; i++) {
fileNames.push(baseName + i + extension);
}
return fileNames;
}
/**
* Generates a random name for a process
*
* @param length {int} If this parameter is not provided the length is set to 5 by default.
* @returns process name
*/
static generateProcessName(length = 5) {
return 'process_' + StringUtil.generateRandomString(length);
}
/**
* Generates a random name for a user task
*
* @param length If this parameter is not provided the length is set to 5 by default.
* @returns task name
*/
static generateUserTaskName(length = 5) {
return 'userTask_' + StringUtil.generateRandomString(length);
}
}
;// CONCATENATED MODULE: external "protractor"
const external_protractor_namespaceObject = require("protractor");
;// CONCATENATED MODULE: external "@alfresco/js-api"
const js_api_namespaceObject = require("@alfresco/js-api");
;// CONCATENATED MODULE: ./src/lib/protractor/core/models/user.model.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class UserModel {
constructor(details = {}) {
this.firstName = StringUtil.generateRandomLowercaseString();
this.lastName = StringUtil.generateRandomLowercaseString();
this.password = StringUtil.generateRandomLowercaseString(4) + StringUtil.generateRandomString(4).toUpperCase();
this.type = 'enterprise';
const EMAIL_DOMAIN = external_protractor_namespaceObject.browser.params?.testConfig?.emailDomain ? external_protractor_namespaceObject.browser.params.testConfig.emailDomain : 'example.com';
this.firstName = details.firstName ? details.firstName : this.firstName;
this.lastName = details.lastName ? details.lastName : this.lastName;
const USER_IDENTIFY = `${this.firstName}${this.lastName}.${StringUtil.generateRandomLowercaseString(5)}`;
this.password = details.password ? details.password : this.password;
this.email = details.email ? details.email : `${USER_IDENTIFY}@${EMAIL_DOMAIN}`;
this.username = details.username ? details.username : USER_IDENTIFY;
this.idIdentityService = details.idIdentityService ? details.idIdentityService : this.idIdentityService;
this.type = details.type ? details.type : this.type;
this.tenantId = details.tenantId ? details.tenantId : this.tenantId;
this.company = details.company ? details.company : this.company;
this.id = details.id ? details.id : this.id;
}
get fullName() {
return `${this.firstName ?? ''} ${this.lastName ?? ''}`;
}
getAPSModel() {
return new js_api_namespaceObject.UserRepresentation({
firstName: this.firstName,
lastName: this.lastName,
password: this.password,
email: this.email,
type: this.type,
tenantId: this.tenantId,
company: this.company,
id: this.id
});
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/identity/roles.service.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class RolesService {
constructor(api) {
this.api = api;
}
async createRole(roleName) {
const path = '/roles';
const method = 'POST';
const queryParams = {};
const postBody = {
name: roleName + 'TestRole'
};
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
async deleteRole(roleId) {
const path = `/roles-by-id/${roleId}`;
const method = 'DELETE';
const queryParams = {};
const postBody = {};
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
async getRoleIdByRoleName(roleName) {
const path = `/roles`;
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
for (const key in data) {
if (data[key].name === roleName) {
return data[key].id;
}
}
return undefined;
}
async getClientRoleIdByRoleName(groupId, clientId, clientRoleName) {
const path = `/groups/${groupId}/role-mappings/clients/${clientId}/available`;
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
for (const key in data) {
if (data[key].name === clientRoleName) {
return data[key].id;
}
}
return undefined;
}
}
;// CONCATENATED MODULE: ./src/lib/shared/utils/logger.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
/* eslint-disable @typescript-eslint/naming-convention */
const infoColor = '\x1b[36m%s\x1b[0m';
const logColor = '\x1b[35m%s\x1b[0m';
const warnColor = '\x1b[33m%s\x1b[0m';
const errorColor = '\x1b[31m%s\x1b[0m';
class LogLevelsEnum extends Number {
}
LogLevelsEnum.TRACE = 5;
LogLevelsEnum.DEBUG = 4;
LogLevelsEnum.INFO = 3;
LogLevelsEnum.WARN = 2;
LogLevelsEnum.ERROR = 1;
LogLevelsEnum.SILENT = 0;
const logLevels = [
{ level: LogLevelsEnum.TRACE, name: 'TRACE' },
{ level: LogLevelsEnum.DEBUG, name: 'DEBUG' },
{ level: LogLevelsEnum.INFO, name: 'INFO' },
{ level: LogLevelsEnum.WARN, name: 'WARN' },
{ level: LogLevelsEnum.ERROR, name: 'ERROR' },
{ level: LogLevelsEnum.SILENT, name: 'SILENT' }
];
/* eslint-disable no-console */
class GenericLogger {
constructor(logLevel) {
this.level = logLevels.find(({ name }) => name === logLevel)?.level || LogLevelsEnum.ERROR;
}
info(...messages) {
if (this.level >= LogLevelsEnum.INFO) {
console.log(infoColor, messages.join(''));
}
}
log(...messages) {
if (this.level >= LogLevelsEnum.TRACE) {
console.log(logColor, messages.join(''));
}
}
warn(...messages) {
if (this.level >= LogLevelsEnum.WARN) {
console.log(warnColor, messages.join(''));
}
}
error(...messages) {
console.log(errorColor, messages.join(''));
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/utils/logger.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
// This was previously a static class, that is why we need this constant starting with uppercase
// Otherwise, feel free to update everywhere in the codebase, where we were using it :)
/* eslint-disable @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match */
const Logger = new GenericLogger(external_protractor_namespaceObject.browser?.params?.testConfig?.appConfig?.log);
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/identity/identity.service.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class IdentityService {
constructor(api) {
this.api = api;
this.ROLES = {
ACTIVITI_USER: 'ACTIVITI_USER',
ACTIVITI_ADMIN: 'ACTIVITI_ADMIN',
ACTIVITI_DEVOPS: 'ACTIVITI_DEVOPS',
ACTIVITI_IDENTITY: 'ACTIVITI_IDENTITY'
};
}
async createIdentityUserWithRole(roles) {
const rolesService = new RolesService(this.api);
const user = await this.createIdentityUser();
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < roles.length; i++) {
const roleId = await rolesService.getRoleIdByRoleName(roles[i]);
await this.assignRole(user.idIdentityService, roleId, roles[i]);
}
return user;
}
async createIdentityUser(user = new UserModel()) {
Logger.log(`Create Identity User ${user.email}`);
await this.createUser(user);
const userIdentity = await this.getUserInfoByUsername(user.username);
await this.resetPassword(userIdentity.id, user.password);
user.idIdentityService = userIdentity.id;
return user;
}
async deleteIdentityUser(userId) {
await this.deleteUser(userId);
}
async createUser(user) {
try {
const path = '/users';
const method = 'POST';
const queryParams = {};
const postBody = {
username: user.username,
firstName: user.firstName,
lastName: user.lastName,
enabled: true,
email: user.email
};
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
catch (error) {
Logger.error('Create User - Service error, Response: ', JSON.parse(JSON.stringify(error))?.response?.text);
}
}
async deleteUser(userId) {
const path = `/users/${userId}`;
const method = 'DELETE';
const queryParams = {};
const postBody = {};
const deletePromise = this.api.performIdentityOperation(path, method, queryParams, postBody);
await deletePromise.then(() => {
Logger.info(`user ${userId} delete`);
});
return deletePromise;
}
async getUserInfoByUsername(username) {
const path = `/users`;
const method = 'GET';
const queryParams = { username };
const 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 = {};
const postBody = { type: 'password', value: password, temporary: false };
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
async addUserToGroup(userId, groupId) {
Logger.log(`Add user to group userId ${userId} ${groupId}`);
try {
const path = `/users/${userId}/groups/${groupId}`;
const method = 'PUT';
const queryParams = {};
const postBody = { realm: 'alfresco', userId, groupId };
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
catch (error) {
Logger.error('Add User To Group - Service error, Response: ', JSON.parse(JSON.stringify(error)));
}
}
async assignRole(userId, roleId, roleName) {
const path = `/users/${userId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {};
const postBody = [{ id: roleId, name: roleName }];
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
async deleteClientRole(userId, clientId, roleId, roleName) {
const path = `/users/${userId}/role-mappings/clients/${clientId}`;
const method = 'DELETE';
const queryParams = {};
const postBody = [{
id: roleId,
name: roleName,
composite: false,
clientRole: true,
containerId: clientId
}];
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
}
;// CONCATENATED MODULE: ./src/lib/shared/api/api.util.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class ApiUtil {
static async waitForApi(apiCall, predicate, retry = 30, delay = 1000) {
const apiCallWithPredicateChecking = async () => {
const apiCallResult = await apiCall();
if (predicate(apiCallResult)) {
return Promise.resolve(apiCallResult);
}
else {
return Promise.reject(apiCallResult);
}
};
return ApiUtil.retryCall(apiCallWithPredicateChecking, retry, delay);
}
static retryCall(fn, retry = 30, delay = 1000) {
const pause = duration => new Promise(res => setTimeout(res, duration));
const run = retries => fn().catch(err => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err)));
return run(retry);
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/identity/group-identity.service.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class GroupIdentityService {
constructor(api) {
this.api = api;
}
async createIdentityGroup(groupName = StringUtil.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 = {};
const postBody = {
name: `${groupName}-${external_protractor_namespaceObject.browser.params.groupSuffix}`
};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async deleteGroup(groupId) {
const path = `/groups/${groupId}`;
const method = 'DELETE';
const queryParams = {};
const postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
async getGroupInfoByGroupName(groupName) {
Logger.log(`Get GroupInfoByGroupName ${groupName}`);
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = `/groups`;
const method = 'GET';
const queryParams = { search: groupName };
const postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
Logger.log(`Data ${JSON.stringify(data)}`);
return data[0];
Logger.error('Group not found');
}
catch (error) {
Logger.error('Group not found');
return null;
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async assignRole(groupId, roleId, roleName) {
Logger.log(`Assign to group ${groupId} Role ${roleName}`);
const path = `/groups/${groupId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {};
const postBody = [{ id: roleId, name: roleName }];
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data;
}
/**
* Add client roles.
*
* @param groupId ID of the target group
* @param clientId ID of the client
* @param roleId ID of the clientRole
* @param roleName of the clientRole
*/
async addClientRole(groupId, clientId, roleId, roleName) {
const path = `/groups/${groupId}/role-mappings/clients/${clientId}`;
const method = 'POST';
const queryParams = {};
const postBody = [
{
id: roleId,
name: roleName,
composite: false,
clientRole: true,
containerId: clientId
}
];
return this.api.performIdentityOperation(path, method, queryParams, postBody);
}
/**
* Gets the client ID using the app name.
*
* @param applicationName Name of the app
* @returns client ID string
*/
async getClientIdByApplicationName(applicationName) {
const path = `/clients`;
const method = 'GET';
const queryParams = { clientId: applicationName };
const postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
return data[0].id;
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/identity/query.service.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class QueryService {
constructor(api) {
this.api = api;
}
async getProcessInstanceTasks(processInstanceId, appName) {
const predicate = (result) => result.list && result.list.entries.length > 0;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
}
catch (error) {
Logger.error('get process-instances tasks Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getProcessInstance(processInstanceId, appName) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId;
const method = 'GET';
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
}
catch (error) {
Logger.error('get process-instances Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getProcessInstanceSubProcesses(processInstanceId, appName) {
const predicate = (result) => result.list && result.list.entries.length > 0;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/subprocesses';
const method = 'GET';
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
}
catch (error) {
Logger.error('get subprocesses process-instances Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getProcessInstanceTaskByStatus(processInstanceId, appName, taskName, status) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data.list?.entries.length && data.list.entries.find(task => task.entry.name === taskName && task.entry.status === status);
}
catch (error) {
Logger.error('get process-instances tasks by status - Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getTaskByStatus(taskName, appName, status, standalone = false) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = `/${appName}/query/v1/tasks?standalone=${standalone}&status=${status}&maxItems=1000&skipCount=0&sort=createdDate`;
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < data.list.entries.length; i++) {
if (data.list.entries[i].entry.name === taskName) {
return data.list.entries[i];
}
}
}
catch (error) {
Logger.error('Get Task By Status - Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getTaskByName(taskName, processInstanceId, appName) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < data.list.entries.length; i++) {
if (data.list.entries[i].entry.name === taskName) {
return data.list.entries[i];
}
}
}
catch (error) {
Logger.error('Get Task By Name - Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getTask(taskName, processInstanceId, appName, status, retryCount = 15) {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {};
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < data.list.entries.length; i++) {
if (data.list.entries[i].entry.name === taskName) {
const task = data.list.entries[i];
if (task.entry.status === status) {
return task;
}
else if (retryCount > 0) {
return this.getTask(taskName, processInstanceId, appName, status, retryCount--);
}
else {
return task;
}
}
}
}
async getTaskByNameAndStatus(taskName, processInstanceId, appName, status) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
return this.getTask(taskName, processInstanceId, appName, status);
}
catch (error) {
Logger.error('Get Task By Name - Service error');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getProcessInstanceId(processName, appName) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances';
const method = 'GET';
const queryParams = { name: processName };
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data.list.entries && data.list.entries.length > 0 ? data.list.entries[0].entry.id : null;
}
catch (error) {
Logger.error('Get Process Instance Id - Service error, Response: ', JSON.parse(JSON.stringify(error))?.response?.text);
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
async getProcessInstances(processName, appName, status) {
const predicate = (result) => !!result;
const apiCall = async () => {
try {
const path = '/' + appName + '/query/v1/process-instances';
const method = 'GET';
let queryParams;
if (status) {
queryParams = { name: processName, status };
}
else {
queryParams = { name: processName };
}
const postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data.list.entries ?? null;
}
catch (error) {
Logger.error('Get Process Instances - Service error, Response: ', JSON.parse(JSON.stringify(error))?.response?.text);
}
};
return ApiUtil.waitForApi(apiCall, predicate, 2, 1000);
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/identity/public-api.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
;// CONCATENATED MODULE: ./src/lib/shared/api/api.service.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class ApiService {
constructor(config, logger) {
this.config = config;
this.logger = logger;
this.logger.log('Api Service configuration' + JSON.stringify(this.config));
this.apiService = new js_api_namespaceObject.AlfrescoApi(this.config.appConfig);
}
getInstance() {
return this.apiService;
}
async login(username, password) {
await this.apiService.login(username, password);
}
/**
* Login using one of the account profiles from the `browser.params.testConfig`.
* Example: loginWithProfile('admin')
*
* @param profileName profile name
*/
async loginWithProfile(profileName) {
const profile = this.config.users[profileName];
if (profile) {
this.logger.log(`try to login with ${profile.username} on HOST: ${this.apiService.config.hostEcm} AUTHTYPE: ${this.apiService.config.authType} PROVIDER: ${this.apiService.config.provider}`);
try {
await this.apiService.login(profile.username, profile.password);
this.logger.log(`Successfuly logged in as ${profile.username}`);
}
catch (error) {
this.logger.error(`Failed to login with ${profile.username}`, error?.message);
throw new Error(`Login failed with ${profile.username}`);
}
}
else {
throw new Error(`Login profile "${profileName}" not found on "browser.params.testConfig".`);
}
}
// @deprecated
async performBpmOperation(path, method, queryParams, postBody) {
return new Promise((resolve, reject) => {
const uri = this.config.appConfig.hostBpm + path;
const pathParams = {};
const formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
// eslint-disable-next-line @typescript-eslint/naming-convention
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
// @deprecated
async performIdentityOperation(path, method, queryParams, postBody) {
return new Promise((resolve, reject) => {
const uri = this.config.appConfig.oauth2.host.replace('/realms', '/admin/realms') + path;
const pathParams = {};
const formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
// eslint-disable-next-line @typescript-eslint/naming-convention
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
// @deprecated
async performECMOperation(path, method, queryParams, postBody) {
return new Promise((resolve, reject) => {
const uri = this.config.appConfig.hostEcm + path;
const pathParams = {};
const formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
// eslint-disable-next-line @typescript-eslint/naming-convention
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
this.apiService.contentClient
.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
}
;// CONCATENATED MODULE: ./src/lib/protractor/core/actions/api.service.factory.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
const createApiService = (
/** @deprecated */
appConfigOverride = {}) => {
const patchedAppConfig = {
...external_protractor_namespaceObject.browser.params.testConfig.appConfig,
oauth2: {
...external_protractor_namespaceObject.browser.params.testConfig.appConfig.oauth2,
// For some reason protractor e2es must have this value hardcoded
implicitFlow: false
},
// Legacy debt...
hostEcm: external_protractor_namespaceObject.browser.params.testConfig.appConfig.ecmHost,
hostBpm: external_protractor_namespaceObject.browser.params.testConfig.appConfig.bpmHost,
...appConfigOverride
};
return new ApiService({
appConfig: new js_api_namespaceObject.AlfrescoApiConfig(patchedAppConfig),
users: external_protractor_namespaceObject.browser.params.testConfig.users
}, Logger);
};
;// CONCATENATED MODULE: external "path"
const external_path_namespaceObject = require("path");
;// CONCATENATED MODULE: external "fs"
const external_fs_namespaceObject = require("fs");
;// CONCATENATED MODULE: external "protractor/built/util"
const util_namespaceObject = require("protractor/built/util");
;// CONCATENATED MODULE: ./src/lib/protractor/core/utils/browser-visibility.ts
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
class BrowserVisibility {
static getVisibleTimeout() {
if (external_protractor_namespaceObject.browser?.params?.testConfig?.timeouts) {
return external_protractor_namespaceObject.browser.params.testConfig.timeouts.visible_timeout;
}
}
static getNoVisibleTimeout() {