mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-12020] Updated init-aps passwords with secret ones (#11993)
* [ACS-12020] Updated init-aps passwords with secret ones * [ACS-12020] deleted last hard coded password
This commit is contained in:
@@ -30,8 +30,11 @@ import { parseArgs } from 'node:util';
|
|||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import { createReadStream } from 'node:fs';
|
import { createReadStream } from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import { config } from 'dotenv';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
|
config({ path: path.resolve(__dirname, '../../../.env') });
|
||||||
|
|
||||||
interface InitApsEnvArgs {
|
interface InitApsEnvArgs {
|
||||||
host?: string;
|
host?: string;
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
@@ -45,6 +48,7 @@ const TENANT_DEFAULT_ID = 1;
|
|||||||
const TENANT_DEFAULT_NAME = 'default';
|
const TENANT_DEFAULT_NAME = 'default';
|
||||||
const CONTENT_DEFAULT_NAME = 'adw-content';
|
const CONTENT_DEFAULT_NAME = 'adw-content';
|
||||||
const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
||||||
|
const E2E_USER_PASSWORD = process.env.HR_USER_PASSWORD;
|
||||||
|
|
||||||
let alfrescoJsApi: AlfrescoApi;
|
let alfrescoJsApi: AlfrescoApi;
|
||||||
|
|
||||||
@@ -152,7 +156,7 @@ Options:
|
|||||||
}
|
}
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
logger.info('Impersonate user: ' + user.username);
|
logger.info('Impersonate user: ' + user.username);
|
||||||
await alfrescoJsApi.login(user.username, 'password');
|
await alfrescoJsApi.login(user.username, E2E_USER_PASSWORD);
|
||||||
await authorizeUserToContentRepo(opts, user);
|
await authorizeUserToContentRepo(opts, user);
|
||||||
|
|
||||||
if (user.username.includes('hruser')) {
|
if (user.username.includes('hruser')) {
|
||||||
@@ -182,7 +186,7 @@ Options:
|
|||||||
*/
|
*/
|
||||||
async function ensureE2eApplicationDeployed(): Promise<boolean> {
|
async function ensureE2eApplicationDeployed(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await alfrescoJsApi.login('hruser', 'password');
|
await alfrescoJsApi.login('hruser', E2E_USER_PASSWORD);
|
||||||
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
|
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
|
||||||
const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions();
|
const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions();
|
||||||
const e2eApp = availableApps.data?.filter((app) => app.name?.includes('e2e-Application'));
|
const e2eApp = availableApps.data?.filter((app) => app.name?.includes('e2e-Application'));
|
||||||
@@ -329,14 +333,13 @@ async function createDefaultTenant(tenantName: string) {
|
|||||||
*/
|
*/
|
||||||
async function createUsers(tenantId: number, user: any) {
|
async function createUsers(tenantId: number, user: any) {
|
||||||
logger.info(`Create user ${user.email} on tenant: ${tenantId}`);
|
logger.info(`Create user ${user.email} on tenant: ${tenantId}`);
|
||||||
const passwordCamelCase = 'Password';
|
|
||||||
const userJson = new UserRepresentation({
|
const userJson = new UserRepresentation({
|
||||||
email: user.email,
|
email: user.email,
|
||||||
firstName: user.firstName,
|
firstName: user.firstName,
|
||||||
lastName: user.lastName,
|
lastName: user.lastName,
|
||||||
status: 'active',
|
status: 'active',
|
||||||
type: 'enterprise',
|
type: 'enterprise',
|
||||||
password: passwordCamelCase,
|
password: E2E_USER_PASSWORD,
|
||||||
tenantId
|
tenantId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -605,7 +608,7 @@ async function authorizeUserToContentRepo(opts: InitApsEnvArgs, user: any) {
|
|||||||
async function authorizeUserToContentWithBasic(opts: InitApsEnvArgs, username: string, contentId: string) {
|
async function authorizeUserToContentWithBasic(opts: InitApsEnvArgs, username: string, contentId: string) {
|
||||||
logger.info(`Authorize ${username} on contentId: ${contentId} in basic auth`);
|
logger.info(`Authorize ${username} on contentId: ${contentId} in basic auth`);
|
||||||
try {
|
try {
|
||||||
const body = { username, password: 'password' };
|
const body = { username, password: E2E_USER_PASSWORD };
|
||||||
const content = await alfrescoJsApi.oauth2Auth.callCustomApi(
|
const content = await alfrescoJsApi.oauth2Auth.callCustomApi(
|
||||||
`${opts.host}/activiti-app/api/enterprise/integration/alfresco/${contentId}/account`,
|
`${opts.host}/activiti-app/api/enterprise/integration/alfresco/${contentId}/account`,
|
||||||
'POST',
|
'POST',
|
||||||
@@ -673,3 +676,5 @@ function formatError(error: any): string {
|
|||||||
function wait(ms: number): Promise<void> {
|
function wait(ms: number): Promise<void> {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|||||||
Reference in New Issue
Block a user