Create Image from PR if request (#6705)

* [create docker image]
fix
fix e2e
[MNT-21636] Use URLTree for redirect (#6691)

* use URLTree for redirect

* use always urltree

* fix e2e

* fix

* fix

* Update release-docker.sh

* update js-api

* update lock
This commit is contained in:
Eugenio Romano
2021-02-23 21:52:26 +00:00
committed by GitHub
parent 63969d65e7
commit 819921deec
11 changed files with 776 additions and 751 deletions

View File

@@ -19,6 +19,8 @@
"superagent",
"event-emitter",
"brace-expansion",
"zen-observable",
"subscriptions-transport-ws",
"d",
"chart.js"
],

View File

@@ -79,8 +79,9 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
const redirectFragment = this.storageService.getItem('loginFragment');
if (redirectFragment && this.getLoginRoute() !== redirectFragment) {
await this.navigate(redirectFragment);
this.storageService.removeItem('loginFragment');
return this.router.parseUrl(redirectFragment);
return false;
}
return true;
@@ -110,9 +111,10 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
return false;
}
protected navigate(url: string): UrlTree {
protected async navigate(url: string): Promise<boolean> {
this.dialog.closeAll();
return this.router.parseUrl(url);
await this.router.navigateByUrl(this.router.parseUrl(url));
return false;
}
protected getOauthConfig(): OauthConfigModel {

View File

@@ -95,7 +95,7 @@ describe('AuthGuardService BPM', () => {
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
}));
it('if the alfresco js api is NOT logged in should trigger a redirect event', async(async () => {
@@ -105,7 +105,8 @@ describe('AuthGuardService BPM', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
}));
it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async(async () => {
@@ -115,20 +116,22 @@ describe('AuthGuardService BPM', () => {
appConfigService.config.oauth2.silentLogin = false;
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should redirect to login url if NOT you are not logged in and silentLogin is false', async(async () => {
it('should redirect url if NOT logged in and isOAuth but no silentLogin configured', async(async () => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = undefined;
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should set redirect url', async(async () => {
it('should set redirect url', async(() => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
@@ -167,13 +170,18 @@ describe('AuthGuardService BPM', () => {
expect(authService.getRedirect()).toEqual('/');
}));
it('should get redirect url from config if there is one configured', async(async () => {
it('should get redirect url from config if there is one configured', async(() => {
appConfigService.config.loginRoute = 'fakeLoginRoute';
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
authGuard.canActivate(null, route);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'BPM', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
}));
it('should to close the material dialog if is redirect to the login', () => {

View File

@@ -72,7 +72,7 @@ describe('AuthGuardService ECM', () => {
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
}));
it('if the alfresco js api is NOT logged in should trigger a redirect event', async(async() => {
@@ -82,7 +82,8 @@ describe('AuthGuardService ECM', () => {
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
}));
it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async(async() => {
@@ -92,7 +93,8 @@ describe('AuthGuardService ECM', () => {
appConfigService.config.oauth2.silentLogin = false;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async(async() => {
@@ -123,7 +125,8 @@ describe('AuthGuardService ECM', () => {
appConfigService.config.oauth2.silentLogin = undefined;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should set redirect navigation commands', async(() => {
@@ -165,13 +168,18 @@ describe('AuthGuardService ECM', () => {
expect(authService.getRedirect()).toEqual('/');
}));
it('should get redirect url from config if there is one configured', async(async () => {
it('should get redirect url from config if there is one configured', async(() => {
appConfigService.config.loginRoute = 'fakeLoginRoute';
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toEqual(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
authGuard.canActivate(null, route);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ECM', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
}));
it('should to close the material dialog if is redirect to the login', () => {

View File

@@ -66,7 +66,8 @@ describe('AuthGuardService', () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'isLoggedIn').and.returnValue(false);
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async(async () => {
@@ -96,7 +97,8 @@ describe('AuthGuardService', () => {
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = false;
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should redirect url if the User is NOT logged in and isOAuth but no silentLogin configured', async(async () => {
@@ -105,7 +107,8 @@ describe('AuthGuardService', () => {
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = undefined;
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/login'));
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should NOT redirect url if the User is NOT logged in and isOAuth but with silentLogin configured', async(async () => {
@@ -125,7 +128,12 @@ describe('AuthGuardService', () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'setRedirect');
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/login?redirectUrl=some-url'));
await authGuard.canActivate(null, state);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ALL', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
}));
it('should set redirect url with query params', async(async () => {
@@ -136,7 +144,12 @@ describe('AuthGuardService', () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'setRedirect');
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/login?redirectUrl=some-url;q=query'));
await authGuard.canActivate(null, state);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ALL', url: 'some-url;q=query'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url;q=query'));
}));
it('should get redirect url from config if there is one configured', async(async () => {
@@ -146,7 +159,12 @@ describe('AuthGuardService', () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'setRedirect');
expect(await authGuard.canActivate(null, state)).toEqual(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
await authGuard.canActivate(null, state);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ALL', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
}));
it('should pass actual redirect when no state segments exists', async(async () => {

View File

@@ -69,7 +69,6 @@ export class AuthGuard extends AuthGuardBase {
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean | UrlTree> {
if (this.authenticationService.isLoggedIn() || this.withCredentials) {
return true;
}
return this.redirectToUrl(redirectUrl);

View File

@@ -20,7 +20,8 @@ import { BrowserActions } from './utils/browser-actions';
import { BrowserVisibility } from './utils/browser-visibility';
export class TestElement {
constructor(public elementFinder: ElementFinder) {}
constructor(public elementFinder: ElementFinder) {
}
static byId(id: string): TestElement {
return new TestElement(element(by.id(id)));
@@ -42,23 +43,41 @@ export class TestElement {
return BrowserActions.click(this.elementFinder);
}
async waitVisible(waitTimeout?: number) {
async isVisible(waitTimeout?: number): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.elementFinder, waitTimeout);
return true;
} catch {
return false;
}
}
async waitVisible(waitTimeout?: number): Promise<any> {
return BrowserVisibility.waitUntilElementIsVisible(this.elementFinder, waitTimeout);
}
async waitNotVisible(waitTimeout?: number) {
async waitNotVisible(waitTimeout?: number): Promise<any> {
return BrowserVisibility.waitUntilElementIsNotVisible(this.elementFinder, waitTimeout);
}
async waitPresent(waitTimeout?: number) {
async isPresent(waitTimeout?: number): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsPresent(this.elementFinder, waitTimeout);
return true;
} catch {
return false;
}
}
async waitPresent(waitTimeout?: number): Promise<any> {
return BrowserVisibility.waitUntilElementIsPresent(this.elementFinder, waitTimeout);
}
async waitNotPresent(waitTimeout?: number) {
async waitNotPresent(waitTimeout?: number): Promise<any> {
return BrowserVisibility.waitUntilElementIsNotPresent(this.elementFinder, waitTimeout);
}
async waitHasValue(value: string) {
async waitHasValue(value: string): Promise<any> {
return BrowserVisibility.waitUntilElementHasValue(this.elementFinder, value);
}
@@ -79,8 +98,8 @@ export class TestElement {
return BrowserActions.getText(this.elementFinder);
}
async typeText(text: string) {
return BrowserActions.clearSendKeys(this.elementFinder, text);
async typeText(text: string): Promise<void> {
await BrowserActions.clearSendKeys(this.elementFinder, text);
}
async clearInput() {

1335
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,7 @@
"process services-cloud"
],
"dependencies": {
"@alfresco/js-api": "^4.3.0-3234",
"@alfresco/js-api": "^4.3.0-3244",
"@angular/animations": "^10.0.4",
"@angular/cdk": "10.1.3",
"@angular/common": "^10.0.4",
@@ -108,8 +108,8 @@
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1001.7",
"@angular-devkit/build-ng-packagr": "~0.1002.0",
"@angular-devkit/build-angular": "^0.1002.2",
"@angular-devkit/build-ng-packagr": "~0.1002.2",
"@angular/cli": "^10.2.2",
"@angular/compiler-cli": "^10.0.12",
"@nrwl/schematics": "8.12.11",

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
if [[ $TRAVIS_BRANCH == "master" ]]; then
TAG_VERSION=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
else
TAG_VERSION=$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER
fi;
echo $TAG_VERSION;

View File

@@ -3,7 +3,15 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ "${TRAVIS_EVENT_TYPE}" == "push" ]];
if [[ $TRAVIS_EVENT_TYPE == "pull_request" ]];
then
HEAD_COMMIT_HASH=${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_COMMIT}}
COMMIT_MESSAGE=`git log --format=%B -n 1 $HEAD_COMMIT_HASH`
fi;
echo " Check Docker Image release for $COMMIT_MESSAGE type $TRAVIS_EVENT_TYPE on branch $TRAVIS_PULL_REQUEST_BRANCH"
if [[ $TRAVIS_EVENT_TYPE == "push" || ( $TRAVIS_EVENT_TYPE == "pull_request" && $COMMIT_MESSAGE == *"[create docker image]"* )]];
then
if [[ $TRAVIS_BRANCH == "develop" || $TRAVIS_BRANCH == "master" ]];
@@ -11,16 +19,27 @@ then
cd $DIR/../../../
# Get Tag Image
TAG_VERSION=$(./scripts/travis/release/get-docker-image-tag-name.sh)
echo "Running the docker with tag" $TAG_VERSION
if [[ $TRAVIS_BRANCH == "master" ]]; then
TAGS=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
else
if [[ "${TRAVIS_PULL_REQUEST_BRANCH}" != "" ]];
then
TAGS=""$TRAVIS_PULL_REQUEST_BRANCH-$TRAVIS_BUILD_NUMBER""
else
TAGS="$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER,$TRAVIS_BRANCH"
fi;
fi;
echo " Running the docker with tag" $TAGS
DOCKER_PROJECT_ARGS="PROJECT_NAME=demo-shell"
# Publish Image to docker
./node_modules/@alfresco/adf-cli/bin/adf-cli docker-publish --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAG_VERSION,$TRAVIS_BRANCH" --pathProject "$(pwd)"
./node_modules/@alfresco/adf-cli/bin/adf-cli docker-publish --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAGS" --pathProject "$(pwd)"
fi;
else
echo "✅ No need to release a docker image"
fi;