[ADF-5353] WS Token refresh (#6774)

* [ADF-5353] WS Toke refresh

* Push UnauthorisedErrorHandler

* Remove Unauthorized error handler

* Remove app.config switch

* Fix unit test test

* Update app.module.ts

* Update task-filters-cloud.component.ts

* Excluded unstable flaky test under review

Co-authored-by: Vito Albano <vito.albano@alfresco.com>
This commit is contained in:
davidcanonieto 2021-03-06 10:22:57 +01:00 committed by GitHub
parent c152df30ab
commit 994b4555af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 37 deletions

View File

@ -462,21 +462,21 @@
"pattern": "cm:name:'(.*?)'",
"field": "cm:name",
"placeholder": "SEARCH.SEARCH_HEADER.FILTERS.NAME.PLACEHOLDER",
"searchSuffix" : "*",
"allowUpdateOnChange" : false
"searchSuffix": "*",
"allowUpdateOnChange": false
}
}
},
{
"id": "checkList",
"name": "SEARCH.SEARCH_HEADER.FILTERS.TYPE.TITLE",
"columnKey":"$thumbnail",
"columnKey": "$thumbnail",
"enabled": true,
"component": {
"selector": "check-list",
"settings": {
"pageSize": 5,
"allowUpdateOnChange" : false,
"allowUpdateOnChange": false,
"operator": "OR",
"options": [
{
@ -494,12 +494,12 @@
{
"id": "contentSize",
"name": "SEARCH.SEARCH_HEADER.FILTERS.SIZE.TITLE",
"columnKey":"content.sizeInBytes",
"columnKey": "content.sizeInBytes",
"enabled": true,
"component": {
"selector": "check-list",
"settings": {
"allowUpdateOnChange" : false,
"allowUpdateOnChange": false,
"options": [
{
"name": "SEARCH.SEARCH_HEADER.FILTERS.SIZE.SMALL",
@ -529,7 +529,7 @@
"component": {
"selector": "date-range",
"settings": {
"allowUpdateOnChange" : false,
"allowUpdateOnChange": false,
"field": "cm:created",
"dateFormat": "DD-MMM-YY",
"maxDate": "today"
@ -1052,22 +1052,24 @@
"ai:textLines": "*"
},
"all-aspects": "*",
"custom-title": [{
"title": "Exif",
"items": [
{
"aspect": "exif:exif",
"editing": false,
"properties": [
"exif:pixelXDimension",
{
"title": "Custom YDimension Name",
"name": "exif:pixelYDimension"
}
]
}
]
}]
"custom-title": [
{
"title": "Exif",
"items": [
{
"aspect": "exif:exif",
"editing": false,
"properties": [
"exif:pixelXDimension",
{
"title": "Custom YDimension Name",
"name": "exif:pixelYDimension"
}
]
}
]
}
]
},
"multi-value-pipe-separator": ", ",
"multi-value-chips": true,
@ -1227,11 +1229,38 @@
}
],
"aspect-visible": {
"default" : ["cm:generalclassifiable", "cm:complianceable",
"cm:dublincore", "cm:effectivity", "cm:summarizable",
"cm:versionable", "cm:templatable","cm:emailed", "emailserver:aliasable",
"cm:taggable", "app:inlineeditable", "cm:geographic", "exif:exif",
"audio:audio", "cm:indexControl", "dp:restrictable", "smf:customConfigSmartFolder", "smf:systemConfigSmartFolder"],
"ai": ["ai:products", "ai:dates", "ai:places", "ai:events", "ai:organizations", "ai:people", "ai:things", "ai:quantities", "ai:creativeWorks", "ai:labels", "ai:textLines"]
"default": [
"cm:generalclassifiable",
"cm:complianceable",
"cm:dublincore",
"cm:effectivity",
"cm:summarizable",
"cm:versionable",
"cm:templatable",
"cm:emailed",
"emailserver:aliasable",
"cm:taggable",
"app:inlineeditable",
"cm:geographic",
"exif:exif",
"audio:audio",
"cm:indexControl",
"dp:restrictable",
"smf:customConfigSmartFolder",
"smf:systemConfigSmartFolder"
],
"ai": [
"ai:products",
"ai:dates",
"ai:places",
"ai:events",
"ai:organizations",
"ai:people",
"ai:things",
"ai:quantities",
"ai:creativeWorks",
"ai:labels",
"ai:textLines"
]
}
}

View File

@ -9,5 +9,5 @@
"C279930": "login problem APS not basic",
"C260241": "ADF-5335- this will exclude 2 tests",
"C587515": "https://alfresco.atlassian.net/browse/ADF-5340",
"C311290": "fix is in the progress by Vito"
"C311290": "https://alfresco.atlassian.net/browse/ADF-5308"
}

View File

@ -17,8 +17,9 @@
import { Apollo } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { split, gql, InMemoryCache } from '@apollo/client/core';
import { split, gql, InMemoryCache, ApolloLink, InMemoryCacheConfig } from '@apollo/client/core';
import { WebSocketLink } from '@apollo/client/link/ws';
import { onError } from '@apollo/client/link/error';
import { getMainDefinition } from '@apollo/client/utilities';
import { Injectable } from '@angular/core';
import { StorageService, AppConfigService, AlfrescoApiService } from '@alfresco/adf-core';
@ -75,9 +76,34 @@ export class NotificationCloudService extends BaseCloudService {
httpLink
);
const errorLink = onError(({ graphQLErrors, operation, forward }) => {
if (graphQLErrors) {
for (const err of graphQLErrors) {
switch (err.extensions.code) {
case 'UNAUTHENTICATED':
const oldHeaders = operation.getContext().headers;
operation.setContext({
headers: {
...oldHeaders,
'X-Authorization': 'Bearer ' + this.storageService.getItem('access_token')
}
});
forward(operation);
break;
default:
}
}
}
});
this.apollo.createNamed(appName, {
link,
cache: new InMemoryCache()
link: ApolloLink.from([errorLink, link]),
cache: new InMemoryCache({ merge: true } as InMemoryCacheConfig),
defaultOptions: {
watchQuery: {
errorPolicy: 'all'
}
}
});
}
}

View File

@ -16,7 +16,7 @@
*/
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { ComponentFixture, TestBed, async, fakeAsync, tick } from '@angular/core/testing';
import { setupTestBed } from '@alfresco/adf-core';
import { from, Observable, of } from 'rxjs';
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
@ -381,10 +381,11 @@ describe('TaskFiltersCloudComponent', () => {
});
}));
it('should update filter counter when notification received', async(() => {
it('should update filter counter when notification received', fakeAsync(() => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
component.appName = 'my-app-1';
component.ngOnInit();
tick(5000);
fixture.detectChanges();
component.showIcons = true;
fixture.whenStable().then(() => {
@ -396,11 +397,12 @@ describe('TaskFiltersCloudComponent', () => {
});
}));
it('should reset filter counter notification when filter is selected', async(() => {
it('should reset filter counter notification when filter is selected', fakeAsync(() => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
let change = new SimpleChange(undefined, 'my-app-1', true);
component.appName = 'my-app-1';
component.ngOnInit();
tick(5000);
fixture.detectChanges();
component.showIcons = true;
fixture.whenStable().then(() => {

View File

@ -20,7 +20,7 @@ import { Observable } from 'rxjs';
import { TaskFilterCloudService } from '../services/task-filter-cloud.service';
import { TaskFilterCloudModel, FilterParamsModel } from '../models/filter-cloud.model';
import { TranslationService } from '@alfresco/adf-core';
import { takeUntil } from 'rxjs/operators';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { BaseTaskFiltersCloudComponent } from './base-task-filters-cloud.component';
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
import { TaskCloudEngineEvent } from '../../../models/engine-event-cloud.model';
@ -98,6 +98,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
initFilterCounterNotifications() {
if (this.appName) {
this.taskFilterCloudService.getTaskNotificationSubscription(this.appName)
.pipe(debounceTime(5000))
.subscribe((result: TaskCloudEngineEvent[]) => {
result.map((taskEvent: TaskCloudEngineEvent) => {
this.checkFilterCounter(taskEvent.entity);