mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-5332] Login basic auth - Ability to override the successRoute from app.config.json (#6651)
* ability to override successRoute from app.config * Add basic doc * Reset the appconfig * Rebase and handle login errors * Remove the default route / * remove space
This commit is contained in:
parent
dc0dc5ef01
commit
3c5d5dc02d
docs/core/components
e2e/process-services
lib
core/login/components
testing/src/lib
@ -225,6 +225,18 @@ export class MyCustomLogin {
|
||||
}
|
||||
```
|
||||
|
||||
### Override the successRoute from app.config.json with Basic Auth
|
||||
|
||||
When the user is logged in the login componet redirect him to the successRoute. This route can be overriden from the app.config.json. The successRoute must to be a valid app route.
|
||||
|
||||
**app.config.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"successRoute" : "/my-landing-page"
|
||||
}
|
||||
```
|
||||
|
||||
### Controlling form submit execution behaviour
|
||||
|
||||
The standard form submission system is suitable for most tasks but you can
|
||||
|
@ -27,7 +27,8 @@ import {
|
||||
UserModel,
|
||||
UsersActions,
|
||||
Widget,
|
||||
SearchService
|
||||
SearchService,
|
||||
Logger
|
||||
} from '@alfresco/adf-testing';
|
||||
import { TasksPage } from './pages/tasks.page';
|
||||
import { browser } from 'protractor';
|
||||
@ -73,32 +74,36 @@ describe('Attach File - Content service', () => {
|
||||
const csIntegrations = ['adf dev', 'adf master'];
|
||||
let user: UserModel;
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeAll(async (done) => {
|
||||
await LocalStorageUtil.setStorageItem('providers', 'ALL');
|
||||
try {
|
||||
await apiService.loginWithProfile('admin');
|
||||
user = await usersActions.createUser();
|
||||
|
||||
await apiService.loginWithProfile('admin');
|
||||
user = await usersActions.createUser();
|
||||
await apiServiceExternal.loginWithProfile('admin');
|
||||
await usersActionsExternal.createUser(user);
|
||||
|
||||
await apiServiceExternal.loginWithProfile('admin');
|
||||
await usersActionsExternal.createUser(user);
|
||||
await integrationService.addCSIntegration({
|
||||
tenantId: user.tenantId,
|
||||
name: csIntegrations[0],
|
||||
host: browser.params.testConfig.appConfig.ecmHost
|
||||
});
|
||||
await integrationService.addCSIntegration({
|
||||
tenantId: user.tenantId,
|
||||
name: csIntegrations[1],
|
||||
host: browser.params.testConfig.adf_external_acs.host
|
||||
});
|
||||
|
||||
await integrationService.addCSIntegration({
|
||||
tenantId: user.tenantId,
|
||||
name: csIntegrations[0],
|
||||
host: browser.params.testConfig.appConfig.ecmHost
|
||||
});
|
||||
await integrationService.addCSIntegration({
|
||||
tenantId: user.tenantId,
|
||||
name: csIntegrations[1],
|
||||
host: browser.params.testConfig.adf_external_acs.host
|
||||
});
|
||||
await apiService.login(user.username, user.password);
|
||||
await uploadActions.uploadFile(pdfFileTwo.location, pdfFileTwo.name, '-my-');
|
||||
await applicationService.importPublishDeployApp(app.file_path);
|
||||
|
||||
await apiService.login(user.username, user.password);
|
||||
await uploadActions.uploadFile(pdfFileTwo.location, pdfFileTwo.name, '-my-');
|
||||
await applicationService.importPublishDeployApp(app.file_path);
|
||||
|
||||
await searchService.isSearchable(pdfFileTwo.name);
|
||||
await searchService.isSearchable(externalFile);
|
||||
await searchService.isSearchable(pdfFileTwo.name);
|
||||
await searchService.isSearchable(externalFile);
|
||||
} catch (error) {
|
||||
console.error('Preconditions failed check if the external env is up and running');
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@ -146,6 +151,7 @@ describe('Attach File - Content service', () => {
|
||||
|
||||
it('[C286516][C299040] Able to upload a file when user has more than two alfresco repositories', async () => {
|
||||
const name = 'Attach file - multiple repo';
|
||||
Logger.log('Step 1 - create task ' + name);
|
||||
await taskPage.createTask({ name, formName: app.UPLOAD_FILE_FORM_CS.formName });
|
||||
|
||||
await widget.attachFileWidget().clickUploadButton(app.UPLOAD_FILE_FORM_CS.FIELD.widget_id);
|
||||
@ -162,20 +168,24 @@ describe('Attach File - Content service', () => {
|
||||
await expect(await widget.attachFileWidget().viewFileEnabled()).toBe(false);
|
||||
await expect(await widget.attachFileWidget().downloadFileEnabled()).toBe(true);
|
||||
await expect(await widget.attachFileWidget().removeFileEnabled()).toBe(true);
|
||||
|
||||
Logger.log('Step 2 - upload file ' + pdfFileTwo.name);
|
||||
await widget.attachFileWidget().clickUploadButton(app.UPLOAD_FILE_FORM_CS.FIELD.widget_id);
|
||||
await widget.attachFileWidget().selectUploadSource(csIntegrations[1]);
|
||||
|
||||
await externalNodeSelector.waitForLogInDialog();
|
||||
Logger.log(`Step 3 - login with user:${user.username}`);
|
||||
await externalNodeSelector.login(user.username, user.password);
|
||||
|
||||
await searchService.isSearchable(externalFile);
|
||||
Logger.log('Step 4 - search and click external file ' + externalFile);
|
||||
await externalNodeSelector.searchAndSelectResult(externalFile, externalFile);
|
||||
await externalNodeSelector.clickMoveCopyButton();
|
||||
|
||||
await widget.attachFileWidget().checkFileIsAttached(app.UPLOAD_FILE_FORM_CS.FIELD.widget_id, externalFile);
|
||||
|
||||
await widget.attachFileWidget().toggleAttachedFileMenu(app.UPLOAD_FILE_FORM_CS.FIELD.widget_id, pdfFileTwo.name);
|
||||
await expect(await widget.attachFileWidget().viewFileEnabled()).toBe(false);
|
||||
Logger.log('Step 5 - download ');
|
||||
await expect(await widget.attachFileWidget().downloadFileEnabled()).toBe(true);
|
||||
await expect(await widget.attachFileWidget().removeFileEnabled()).toBe(true);
|
||||
|
||||
@ -183,10 +193,11 @@ describe('Attach File - Content service', () => {
|
||||
await expect(await widget.attachFileWidget().viewFileEnabled()).toBe(false);
|
||||
await expect(await widget.attachFileWidget().downloadFileEnabled()).toBe(false);
|
||||
await expect(await widget.attachFileWidget().removeFileEnabled()).toBe(true);
|
||||
|
||||
Logger.log('Step 6 - download ');
|
||||
await taskPage.taskDetails().clickCompleteFormTask();
|
||||
|
||||
await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.COMPLETED_TASKS);
|
||||
Logger.log('Step 7 - go filter completed ');
|
||||
await taskPage.tasksListPage().selectRow(name);
|
||||
|
||||
await widget.attachFileWidget().checkFileIsAttached(app.UPLOAD_FILE_FORM_CS.FIELD.widget_id, pdfFileTwo.name);
|
||||
|
@ -124,7 +124,44 @@ describe('LoginComponent', () => {
|
||||
expect(router.navigate).toHaveBeenCalledWith([redirect]);
|
||||
});
|
||||
|
||||
it('should use the input successRoute as redirect if defined', () => {
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(router, 'navigate');
|
||||
|
||||
component.successRoute = 'input-route';
|
||||
appConfigService.config = {};
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['input-route']);
|
||||
});
|
||||
|
||||
it('should use the successRoute route from app.config if the input successRoute is NOT defined', () => {
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(router, 'navigate');
|
||||
|
||||
component.successRoute = undefined;
|
||||
appConfigService.config.successRoute = 'route-app-config';
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['route-app-config']);
|
||||
});
|
||||
|
||||
it('should use the successRoute route from app.config if both successRoute are defined', () => {
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(router, 'navigate');
|
||||
|
||||
component.successRoute = 'input-route';
|
||||
appConfigService.config.successRoute = 'route-app-config';
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['route-app-config']);
|
||||
});
|
||||
|
||||
it('should redirect to previous route state on successful login', () => {
|
||||
appConfigService.config = {};
|
||||
appConfigService.config.providers = 'ECM';
|
||||
|
||||
spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket' }));
|
||||
|
@ -150,6 +150,8 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
this.initFormFieldsDefault();
|
||||
this.initFormFieldsMessages();
|
||||
|
||||
this.successRoute = this.appConfig.get<string>('successRoute', this.successRoute);
|
||||
|
||||
if (this.authService.isLoggedIn()) {
|
||||
this.router.navigate([this.successRoute]);
|
||||
} else {
|
||||
|
@ -93,7 +93,13 @@ export class ApiService {
|
||||
async loginWithProfile(profileName: string): Promise<void> {
|
||||
const profile = browser.params.testConfig.users[profileName];
|
||||
if (profile) {
|
||||
await this.apiService.login(profile.username, profile.password);
|
||||
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);
|
||||
} catch (error) {
|
||||
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".`);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import { BrowserActions } from '../../core/utils/browser-actions';
|
||||
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||
import { ContentNodeSelectorDialogPage } from '../../content-services/dialog/content-node-selector-dialog.page';
|
||||
import { DocumentListPage } from '../../content-services/pages/document-list.page';
|
||||
|
||||
import { Logger } from '../../core/utils/logger';
|
||||
export class ExternalNodeSelectorDialogPage extends ContentNodeSelectorDialogPage {
|
||||
txtUsername = element(by.css('input[id="username"]'));
|
||||
txtPassword = element(by.css('input[id="password"]'));
|
||||
@ -63,6 +63,7 @@ export class ExternalNodeSelectorDialogPage extends ContentNodeSelectorDialogPag
|
||||
}
|
||||
|
||||
async login(username, password): Promise<void> {
|
||||
Logger.log('Login external With ' + username);
|
||||
await this.waitForLogInDialog();
|
||||
await this.enterUsername(username);
|
||||
await this.enterPassword(password);
|
||||
|
Loading…
x
Reference in New Issue
Block a user