mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-259] refactor login page (#5733)
* refator login page * refator login page * remove obsolete classes and move what is needed in the test pck * fix const * revert modify * remove duplicate browser property * fix build * fix * fix * fix lint * move drop action in testing remove not necessary space js-api centralize content * first refactor use js-api * fix protractor * refactor test config * simplify properties fix namings * ps cloud simplify remove unused js files * id fix * fix search test simplify environment var step 1 * fix lint * first user iteration fix * fix model * unify use of apiService * first step automatic user creation Identity * refactor creation user content-services * refactor creation user search * refactor creation user core * process service refactoring 1 * process service refactoring 1 * process service refactoring 2 * fix process * appconfig * fix process util * fix gallery * fix "this" reference issues * fix incorrect import paths * fix core * some fixes * allign * fix some test remove structure folder and move in actions * fixes * move folders in the right place * fix * fix rebase * solve build issue * fix e2e * change init aae * order api and some fixes * fix possible not valid password * fix some ps test * replace host port also in objects * Update app-config.service.ts * fix process * fix process test * process service cloud fix * fiexs * modify init script * fix two test * remove unused property * host issue * not use npx * fix ps cloud test Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
This commit is contained in:
3105
lib/cli/package-lock.json
generated
3105
lib/cli/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^4.0.0",
|
||||
"@alfresco/adf-testing": "3.8.0",
|
||||
"license-checker": "^25.0.1",
|
||||
"npm-registry-fetch": "^3.9.0",
|
||||
"@angular-devkit/core": "^7.2.15",
|
||||
|
@@ -17,7 +17,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ACTIVITI_CLOUD_APPS, DeploymentAPI, ModelingAPI } from '@alfresco/adf-testing';
|
||||
import * as program from 'commander';
|
||||
|
||||
/* tslint:disable */
|
||||
@@ -27,6 +26,10 @@ import request = require('request');
|
||||
import * as fs from 'fs';
|
||||
import { logger } from './logger';
|
||||
|
||||
let alfrescoJsApi: any;
|
||||
let args: ConfigArgs;
|
||||
let isValid = true;
|
||||
|
||||
export interface ConfigArgs {
|
||||
modelerUsername: string;
|
||||
modelerPassword: string;
|
||||
@@ -38,45 +41,168 @@ export interface ConfigArgs {
|
||||
identityHost: boolean;
|
||||
}
|
||||
|
||||
let browser: any;
|
||||
let deploymentAPI: DeploymentAPI;
|
||||
let modelingAPI: ModelingAPI;
|
||||
|
||||
export const AAE_MICROSERVICES = [
|
||||
'deployment-service',
|
||||
'modeling-service',
|
||||
'dmn-service'
|
||||
];
|
||||
|
||||
async function healthCheck(args: ConfigArgs, apiService: any, nameService: string, result: any) {
|
||||
async function healthCheck(nameService: string) {
|
||||
const url = `${args.host}/${nameService}/actuator/health`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
const health = await apiService.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
const health = await alfrescoJsApi.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
if (health.status !== 'UP' ) {
|
||||
if (health.status !== 'UP') {
|
||||
logger.error(`${nameService} is DOWN `);
|
||||
result.isValid = false;
|
||||
isValid = false;
|
||||
} else {
|
||||
logger.info(`${nameService} is UP!`);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(`${nameService} is not reachable ${error.status} `);
|
||||
result.isValid = false;
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getAlfrescoJsApiInstance(args: ConfigArgs) {
|
||||
function getApplicationByStatus(status: string) {
|
||||
const url = `${args.host}/deployment-service/v1/applications/`;
|
||||
|
||||
const pathParams = {}, queryParams = { status: status },
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getDescriptors() {
|
||||
const url = `${args.host}/deployment-service/v1/descriptors`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getProjects() {
|
||||
const url = `${args.host}/deployment-service/v1/projects/'`;
|
||||
|
||||
const pathParams = {}, queryParams = { maxItems: 1000 },
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getProjectRelease(projectId: string) {
|
||||
const url = `${args.host}/deployment-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function releaseProject(projectId: string) {
|
||||
const url = `${args.host}/deployment-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'POST', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function importAndReleaseProject(absoluteFilePath: string) {
|
||||
const fileContent = await fs.createReadStream(absoluteFilePath);
|
||||
|
||||
try {
|
||||
const project = await alfrescoJsApi.oauth2Auth.callCustomApi(`${args.host}/v1/projects/import`, 'POST', {}, {}, {}, { file: fileContent }, {}, ['multipart/form-data'], ['application/json']);
|
||||
|
||||
await alfrescoJsApi.oauth2Auth.callCustomApi(`${args.host}/v1/projects/${project.entry.id}/releases`, 'POST', {}, {}, {}, {}, {},
|
||||
['application/json'], ['application/json']);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteDescriptor(name: string) {
|
||||
const url = `${args.host}/v1/descriptors/${name}`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function deploy(model: any) {
|
||||
const url = `${args.host}/v1/applications/`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = model,
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
try {
|
||||
return alfrescoJsApi.oauth2Auth.callCustomApi(url, 'POST', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
|
||||
} catch (error) {
|
||||
logger.error(error.status);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getAlfrescoJsApiInstance(configArgs: ConfigArgs) {
|
||||
const config = {
|
||||
provider: 'BPM',
|
||||
hostBpm: `${args.host}`,
|
||||
hostBpm: `${configArgs.host}`,
|
||||
authType: 'OAUTH',
|
||||
oauth2: {
|
||||
host: `${args.oauth}`,
|
||||
clientId: `${args.clientId}`,
|
||||
host: `${configArgs.oauth}/auth/realms/alfresco`,
|
||||
clientId: `${configArgs.clientId}`,
|
||||
scope: 'openid',
|
||||
secret: '',
|
||||
implicitFlow: false,
|
||||
@@ -87,19 +213,8 @@ function getAlfrescoJsApiInstance(args: ConfigArgs) {
|
||||
return new alfrescoApi.AlfrescoApiCompatibility(config);
|
||||
}
|
||||
|
||||
async function login(args: ConfigArgs, alfrescoJsApi: any) {
|
||||
logger.info(`Perform login...`);
|
||||
try {
|
||||
await alfrescoJsApi.login(args.modelerUsername, args.modelerPassword);
|
||||
} catch (error) {
|
||||
logger.error(`Not able to login. Credentials ${args.modelerUsername}:${args.modelerPassword} are not valid`);
|
||||
process.exit(1);
|
||||
}
|
||||
return alfrescoJsApi;
|
||||
}
|
||||
|
||||
async function deployMissingApps() {
|
||||
const deployedApps = await deploymentAPI.getApplicationByStatus('');
|
||||
const deployedApps = await getApplicationByStatus('');
|
||||
const absentApps = findMissingApps(deployedApps.list.entries);
|
||||
|
||||
if (absentApps.length > 0) {
|
||||
@@ -111,7 +226,7 @@ async function deployMissingApps() {
|
||||
}
|
||||
|
||||
async function checkIfAppIsReleased(absentApps: any []) {
|
||||
const projectList = await modelingAPI.getProjects();
|
||||
const projectList = await getProjects();
|
||||
let TIME = 5000;
|
||||
let noError = true;
|
||||
|
||||
@@ -147,11 +262,11 @@ async function checkIfAppIsReleased(absentApps: any []) {
|
||||
|
||||
logger.info('Project ' + project.entry.name + ' found');
|
||||
|
||||
const projectReleaseList = await modelingAPI.getProjectRelease(project.entry.id);
|
||||
const projectReleaseList = await getProjectRelease(project.entry.id);
|
||||
|
||||
if (projectReleaseList.list.entries.length === 0) {
|
||||
logger.warn('Project needs release');
|
||||
projectRelease = await modelingAPI.releaseProject(project);
|
||||
projectRelease = await releaseProject(project);
|
||||
logger.warn(`Project released: ${projectRelease.id}`);
|
||||
} else {
|
||||
logger.info('Project already has release');
|
||||
@@ -177,18 +292,18 @@ async function checkIfAppIsReleased(absentApps: any []) {
|
||||
'infrastructure': currentAbsentApp.infrastructure,
|
||||
'variables': currentAbsentApp.variables
|
||||
};
|
||||
await deploymentAPI.deploy(deployPayload);
|
||||
await deploy(deployPayload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkDescriptorExist(name: string) {
|
||||
logger.info(`Check descriptor ${name} exist in the list `);
|
||||
const descriptorList = await deploymentAPI.getDescriptors();
|
||||
descriptorList.list.entries.forEach( async(descriptor: any) => {
|
||||
const descriptorList = await getDescriptors();
|
||||
descriptorList.list.entries.forEach(async (descriptor: any) => {
|
||||
if (descriptor.entry.name === name) {
|
||||
if (descriptor.entry.deployed === false) {
|
||||
await deploymentAPI.deleteDescriptor(descriptor.entry.name);
|
||||
await deleteDescriptor(descriptor.entry.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -198,20 +313,20 @@ async function checkDescriptorExist(name: string) {
|
||||
async function importProjectAndRelease(app: any) {
|
||||
await getFileFromRemote(app.file_location, app.name);
|
||||
logger.warn('Project imported ' + app.name);
|
||||
const result = await modelingAPI.importAndReleaseProject(`${app.name}.zip`);
|
||||
const projectRelease = await importAndReleaseProject(`${app.name}.zip`);
|
||||
deleteLocalFile(`${app.name}`);
|
||||
return result;
|
||||
return projectRelease;
|
||||
}
|
||||
|
||||
function findMissingApps(deployedApps: any []) {
|
||||
const absentApps: any [] = [];
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
['candidatebaseapp', 'simpleapp', 'subprocessapp'].forEach((app) => {
|
||||
const isPresent = deployedApps.find((currentApp: any) => {
|
||||
return ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name;
|
||||
return app === currentApp.entry.name;
|
||||
});
|
||||
|
||||
if (!isPresent) {
|
||||
absentApps.push(ACTIVITI_CLOUD_APPS[key]);
|
||||
absentApps.push(app);
|
||||
}
|
||||
});
|
||||
return absentApps;
|
||||
@@ -220,14 +335,14 @@ function findMissingApps(deployedApps: any []) {
|
||||
async function getFileFromRemote(url: string, name: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url)
|
||||
.pipe(fs.createWriteStream(`${name}.zip`))
|
||||
.on('finish', () => {
|
||||
logger.info(`The file is finished downloading.`);
|
||||
resolve();
|
||||
})
|
||||
.on('error', (error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
.pipe(fs.createWriteStream(`${name}.zip`))
|
||||
.on('finish', () => {
|
||||
logger.info(`The file is finished downloading.`);
|
||||
resolve();
|
||||
})
|
||||
.on('error', (error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -243,49 +358,13 @@ async function sleep(time: number) {
|
||||
return;
|
||||
}
|
||||
|
||||
async function initConfiguration(args: ConfigArgs) {
|
||||
browser = {
|
||||
params: {
|
||||
config: {
|
||||
log: true
|
||||
},
|
||||
adminapp: {
|
||||
apiConfig: {
|
||||
authType: 'OAUTH',
|
||||
identityHost: args.identityHost,
|
||||
oauth2: {
|
||||
host: args.oauth,
|
||||
authPath: '/protocol/openid-connect/token/',
|
||||
clientId: args.clientId,
|
||||
scope: 'openid',
|
||||
implicitFlow: false,
|
||||
redirectUri: ''
|
||||
},
|
||||
bpmHost: args.host,
|
||||
providers: 'BPM'
|
||||
},
|
||||
modeler: args.modelerUsername,
|
||||
modeler_password: args.modelerPassword,
|
||||
devops: args.devopsUsername,
|
||||
devops_password: args.devopsPassword
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global['protractor'] = {browser: browser};
|
||||
|
||||
deploymentAPI = new DeploymentAPI();
|
||||
modelingAPI = new ModelingAPI();
|
||||
|
||||
await deploymentAPI.setUp();
|
||||
await modelingAPI.setUp();
|
||||
export default async function (configArgs: ConfigArgs) {
|
||||
await main(configArgs);
|
||||
}
|
||||
|
||||
export default async function (args: ConfigArgs) {
|
||||
await main(args);
|
||||
}
|
||||
async function main(configArgs: ConfigArgs) {
|
||||
|
||||
async function main(args: ConfigArgs) {
|
||||
args = configArgs;
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
@@ -293,6 +372,7 @@ async function main(args: ConfigArgs) {
|
||||
'adf-cli init-aae-env --host "gateway_env" --oauth "identity_env" --identityHost "identity_env" --modelerUsername "modelerusername" --modelerPassword "modelerpassword" --devopsUsername "devevopsusername" --devopsPassword "devopspassword"')
|
||||
.option('-h, --host [type]', 'Host gateway')
|
||||
.option('-o, --oauth [type]', 'Host sso server')
|
||||
.option('-jsonAppsPath, --oauth [type]', 'Host sso server')
|
||||
.option('--clientId[type]', 'sso client')
|
||||
.option('--modelerUsername [type]', 'username of a user with role ACTIVIT_MODELER')
|
||||
.option('--modelerPassword [type]', 'modeler password')
|
||||
@@ -305,22 +385,19 @@ async function main(args: ConfigArgs) {
|
||||
return;
|
||||
}
|
||||
|
||||
await initConfiguration(args);
|
||||
|
||||
const alfrescoJsApi = getAlfrescoJsApiInstance(args);
|
||||
await login(args, alfrescoJsApi);
|
||||
|
||||
const result = { isValid: true };
|
||||
alfrescoJsApi = getAlfrescoJsApiInstance(args);
|
||||
await alfrescoJsApi.login(args.modelerUsername, args.modelerPassword);
|
||||
|
||||
AAE_MICROSERVICES.map(async (serviceName) => {
|
||||
await healthCheck(args, alfrescoJsApi, serviceName, result);
|
||||
await healthCheck(serviceName);
|
||||
});
|
||||
|
||||
if (result.isValid) {
|
||||
if (isValid) {
|
||||
logger.error('The environment is up and running');
|
||||
await alfrescoJsApi.login(args.devopsUsername, args.devopsPassword);
|
||||
await deployMissingApps();
|
||||
} else {
|
||||
logger.error('The environment is not up');
|
||||
logger.info('The environment is not up');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user