[ADF-3191] Fix userprefrence oauth2 (#3488)

* remove user preference setting save

* fix host setting test

* remove userPreferences test

* fix title service test

* remove unused imports

* restore input align

* fix service import in test tag rating
This commit is contained in:
Eugenio Romano
2018-06-15 08:32:16 +01:00
committed by GitHub
parent af2cde0791
commit 8966e22487
43 changed files with 417 additions and 528 deletions

View File

@@ -1,5 +1,7 @@
// Place your settings in this file to overwrite default and user settings. // Place your settings in this file to overwrite default and user settings.
{ {
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"files.exclude": { "files.exclude": {
"**/.git": true, "**/.git": true,
"**/.svn": true, "**/.svn": true,
@@ -9,6 +11,8 @@
"**/.happypack": true "**/.happypack": true
}, },
"editor.renderIndentGuides": true, "editor.renderIndentGuides": true,
"window.zoomLevel": 8,
"html.format.wrapAttributes": "force",
"markdownlint.config": { "markdownlint.config": {
"MD032": false, "MD032": false,
"MD004": false, "MD004": false,
@@ -19,8 +23,5 @@
"MD033": false, "MD033": false,
"MD031": false "MD031": false
}, },
"cSpell.words": [ "cSpell.words": ["mincount", "webscript"]
"mincount",
"webscript"
]
} }

View File

@@ -6,7 +6,7 @@ import { ChartsModule } from 'ng2-charts';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppConfigService, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; import { AppConfigService, TRANSLATION_PROVIDER, DebugAppConfigService } from '@alfresco/adf-core';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AdfModule } from './adf.module'; import { AdfModule } from './adf.module';
import { MaterialModule } from './material.module'; import { MaterialModule } from './material.module';
@@ -43,7 +43,6 @@ import { MetadataDialogAdapterComponent } from './components/files/metadata-dial
import { BlobPreviewComponent } from './components/blob-preview/blob-preview.component'; import { BlobPreviewComponent } from './components/blob-preview/blob-preview.component';
import { ThemePickerModule } from './components/theme-picker/theme-picker'; import { ThemePickerModule } from './components/theme-picker/theme-picker';
import { DebugAppConfigService } from './services/debug-app-config.service';
import { routing } from './app.routes'; import { routing } from './app.routes';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms';
@@ -110,7 +109,7 @@ import { NotificationsComponent } from './components/notifications/notifications
NotificationsComponent NotificationsComponent
], ],
providers: [ providers: [
{ provide: AppConfigService, useClass: DebugAppConfigService }, { provide: AppConfigService, useClass: DebugAppConfigService }, // not use this service in production
{ {
provide: TRANSLATION_PROVIDER, provide: TRANSLATION_PROVIDER,
multi: true, multi: true,
@@ -129,11 +128,7 @@ import { NotificationsComponent } from './components/notifications/notifications
}, },
PreviewService PreviewService
], ],
entryComponents: [ entryComponents: [VersionManagerDialogAdapterComponent, MetadataDialogAdapterComponent],
VersionManagerDialogAdapterComponent,
MetadataDialogAdapterComponent
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { export class AppModule {}
}

View File

@@ -25,7 +25,7 @@ import { MatDialog } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry } from 'alfresco-js-api'; import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry } from 'alfresco-js-api';
import { import {
AuthenticationService, ContentService, TranslationService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService,
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService, FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
UploadService, DataColumn, DataRow, UserPreferencesService, UploadService, DataColumn, DataRow, UserPreferencesService,
PaginationComponent, FormValues, DisplayMode, UserPreferenceValues, InfinitePaginationComponent PaginationComponent, FormValues, DisplayMode, UserPreferenceValues, InfinitePaginationComponent
@@ -56,7 +56,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
displayMode = DisplayMode.List; displayMode = DisplayMode.List;
includeFields = ['isFavorite', 'isLocked', 'aspectNames']; includeFields = ['isFavorite', 'isLocked', 'aspectNames'];
baseShareUrl = this.preference.ecmHost + '/preview/s/'; baseShareUrl = this.appConfig.get<string>(AppConfigValues.ECMHOST) + '/preview/s/';
toolbarColor = 'default'; toolbarColor = 'default';
@@ -188,6 +188,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
private translateService: TranslationService, private translateService: TranslationService,
private router: Router, private router: Router,
private logService: LogService, private logService: LogService,
private appConfig: AppConfigService,
private preference: UserPreferencesService, private preference: UserPreferencesService,
private preview: PreviewService, private preview: PreviewService,
@Optional() private route: ActivatedRoute, @Optional() private route: ActivatedRoute,

View File

@@ -15,6 +15,8 @@ that the component is complete and suitable for normal use. The other status lev
but is now obsolete and will probably be removed in a future version of ADF. but is now obsolete and will probably be removed in a future version of ADF.
- **Experimental** ![](docassets/images/ExperimentalIcon.png) - The component is available for - **Experimental** ![](docassets/images/ExperimentalIcon.png) - The component is available for
experimentation but not fully complete and tested for production code. experimentation but not fully complete and tested for production code.
- **Internal** ![](docassets/images/InternalIcon.png) - The component is available for
internal test use but not meant to be used in production
There is also a set of ADF tutorials that describe how to accomplish tasks step-by-step. There is also a set of ADF tutorials that describe how to accomplish tasks step-by-step.
See the [Tutorials index](tutorials/README.md) for the full list. See the [Tutorials index](tutorials/README.md) for the full list.

View File

@@ -10,7 +10,7 @@ Displays the version history of a node with the ability to upload a new version.
![Version Manager](../docassets/images/version-manager.png) ![Version Manager](../docassets/images/version-manager.png)
![\#f03c15](https://placehold.it/15/f03c15/000000?text=+) `This component is still in experimental phase. It has several limitations which will be resolved soon.` `This component is still in experimental phase. It has several limitations which will be resolved soon.`
## Basic Usage ## Basic Usage

View File

@@ -32,7 +32,7 @@ for more information about installing and using the source code.
| [Infinite pagination component](infinite-pagination.component.md) | Adds "infinite" pagination to the component it is used with. | [Source](../../lib/core/pagination/infinite-pagination.component.ts) | | [Infinite pagination component](infinite-pagination.component.md) | Adds "infinite" pagination to the component it is used with. | [Source](../../lib/core/pagination/infinite-pagination.component.ts) |
| [Pagination component](pagination.component.md) | Adds pagination to the component it is used with. | [Source](../../lib/core/pagination/pagination.component.ts) | | [Pagination component](pagination.component.md) | Adds pagination to the component it is used with. | [Source](../../lib/core/pagination/pagination.component.ts) |
| [Host settings component](host-settings.component.md) | Validates the URLs for ACS and APS and saves them in the user's local storage | [Source](../../lib/core/settings/host-settings.component.ts) | | [Host settings component](host-settings.component.md) | Validates the URLs for ACS and APS and saves them in the user's local storage | [Source](../../lib/core/settings/host-settings.component.ts) |
| [Sidebar action menu component](sidebar-action-menu.component.md) | Displays a sidebar-action menu information panel. | [Source](../../lib/core/sidenav-layout/components/sidebar-action/sidebar-action-menu.component.ts) | | [Sidebar action menu component](sidebar-action-menu.component.md) ![Internal](docassets/images/InternalIcon.png) | Displays a sidebar-action menu information panel. | [Source](../../lib/core/sidenav-layout/components/sidebar-action/sidebar-action-menu.component.ts) |
| [Sidenav layout component](sidenav-layout.component.md) | Displays the standard three-region ADF application layout. | [Source](../../lib/core/sidenav-layout/components/sidenav-layout/sidenav-layout.component.ts) | | [Sidenav layout component](sidenav-layout.component.md) | Displays the standard three-region ADF application layout. | [Source](../../lib/core/sidenav-layout/components/sidenav-layout/sidenav-layout.component.ts) |
| [Sorting picker component](sorting-picker.component.md) | Selects from a set of predefined sorting definitions and directions. | [Source](../../lib/core/sorting-picker/sorting-picker.component.ts) | | [Sorting picker component](sorting-picker.component.md) | Selects from a set of predefined sorting definitions and directions. | [Source](../../lib/core/sorting-picker/sorting-picker.component.ts) |
| [Empty content component](empty-content.component.md) | Provides a generic "Empty Content" placeholder for components. | [Source](../../lib/core/templates/empty-content/empty-content.component.ts) | | [Empty content component](empty-content.component.md) | Provides a generic "Empty Content" placeholder for components. | [Source](../../lib/core/templates/empty-content/empty-content.component.ts) |

View File

@@ -1,11 +1,12 @@
--- ---
Added: v2.0.0 Added: v2.0.0
Status: Active Status: Internal
Last reviewed: 2018-06-13 Last reviewed: 2018-06-13
--- ---
# Host settings component # Host settings component
`This component Note this comonent is not meant to be used in production`
Validates the URLs for ACS and APS and saves them in the user's local storage Validates the URLs for ACS and APS and saves them in the user's local storage
![Host settings](../docassets/images/host-settings-component.png) ![Host settings](../docassets/images/host-settings-component.png)
@@ -17,6 +18,15 @@ Validates the URLs for ACS and APS and saves them in the user's local storage
</adf-host-settings> </adf-host-settings>
``` ```
```ts
@NgModule({
providers: [
{ provide: AppConfigService, useClass: DebugAppConfigService },
]
)]
```
## Class members ## Class members
### Properties ### Properties

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

View File

@@ -15,15 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { AlfrescoApiServiceMock, AppConfigService, ContentService,
AlfrescoApiServiceMock, StorageService, setupTestBed, CoreModule, TranslationMock
AppConfigService,
ContentService,
StorageService,
UserPreferencesService,
setupTestBed,
CoreModule,
TranslationMock
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { FileNode, FolderNode } from '../../mock'; import { FileNode, FolderNode } from '../../mock';
import { ContentActionHandler } from '../models/content-action.model'; import { ContentActionHandler } from '../models/content-action.model';
@@ -31,14 +24,12 @@ import { DocumentActionsService } from './document-actions.service';
import { DocumentListService } from './document-list.service'; import { DocumentListService } from './document-list.service';
import { NodeActionsService } from './node-actions.service'; import { NodeActionsService } from './node-actions.service';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { TestBed } from '@angular/core/testing';
describe('DocumentActionsService', () => { describe('DocumentActionsService', () => {
let service: DocumentActionsService; let service: DocumentActionsService;
let documentListService: DocumentListService; let documentListService: DocumentListService;
let nodeActionsService: NodeActionsService; let nodeActionsService: NodeActionsService;
let userPreferences;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -47,9 +38,8 @@ describe('DocumentActionsService', () => {
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService);
let contentService = new ContentService(null, null, null, null); let contentService = new ContentService(null, null, null, null);
let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()); let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null); documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService); service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);

View File

@@ -16,9 +16,8 @@
*/ */
import { AlfrescoApiServiceMock, AlfrescoApiService, import { AlfrescoApiServiceMock, AlfrescoApiService,
AppConfigService, StorageService, ContentService, UserPreferencesService, setupTestBed, CoreModule } from '@alfresco/adf-core'; AppConfigService, StorageService, ContentService, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { DocumentListService } from './document-list.service'; import { DocumentListService } from './document-list.service';
import { TestBed } from '@angular/core/testing';
declare let jasmine: any; declare let jasmine: any;
@@ -26,7 +25,6 @@ describe('DocumentListService', () => {
let service: DocumentListService; let service: DocumentListService;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
let userPreferences: UserPreferencesService;
let fakeEntryNode = { let fakeEntryNode = {
'entry': { 'entry': {
@@ -96,10 +94,8 @@ describe('DocumentListService', () => {
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService);
let contentService = new ContentService(null, null, null, null); let contentService = new ContentService(null, null, null, null);
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()); alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
service = new DocumentListService(null, contentService, alfrescoApiService, null, null); service = new DocumentListService(null, contentService, alfrescoApiService, null, null);
jasmine.Ajax.install(); jasmine.Ajax.install();
}); });

View File

@@ -16,7 +16,7 @@
*/ */
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AlfrescoApiServiceMock, AppConfigService, StorageService, ContentService, setupTestBed, CoreModule, TranslationMock, UserPreferencesService } from '@alfresco/adf-core'; import { AlfrescoApiServiceMock, AppConfigService, StorageService, ContentService, setupTestBed, CoreModule, TranslationMock } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { FileNode, FolderNode } from '../../mock'; import { FileNode, FolderNode } from '../../mock';
import { ContentActionHandler } from '../models/content-action.model'; import { ContentActionHandler } from '../models/content-action.model';
@@ -27,7 +27,6 @@ describe('FolderActionsService', () => {
let service: FolderActionsService; let service: FolderActionsService;
let documentListService: DocumentListService; let documentListService: DocumentListService;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -39,10 +38,8 @@ describe('FolderActionsService', () => {
let appConfig: AppConfigService = TestBed.get(AppConfigService); let appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm'; appConfig.config.ecmHost = 'http://localhost:9876/ecm';
userPreferences = TestBed.get(UserPreferencesService);
let contentService = new ContentService(null, null, null, null); let contentService = new ContentService(null, null, null, null);
let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()); let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null); documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock()); service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
}); });

View File

@@ -15,27 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoApiServiceMock, AppConfigService, StorageService, setupTestBed, CoreModule, UserPreferencesService } from '@alfresco/adf-core';
import { RatingService } from './rating.service';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { setupTestBed } from '@alfresco/adf-core';
import { RatingService } from './rating.service';
import { ContentTestingModule } from '../../testing/content.testing.module';
declare let jasmine: any; declare let jasmine: any;
describe('Rating service', () => { describe('Rating service', () => {
let service; let service;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [ContentTestingModule]
CoreModule.forRoot()
]
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService); service = TestBed.get(RatingService);
service = new RatingService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()));
}); });
beforeEach(() => { beforeEach(() => {

View File

@@ -15,26 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoApiServiceMock, LogService, AppConfigService, StorageService, setupTestBed, CoreModule, UserPreferencesService } from '@alfresco/adf-core'; import { setupTestBed } from '@alfresco/adf-core';
import { TagService } from './tag.service'; import { TagService } from './tag.service';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ContentTestingModule } from '../../testing/content.testing.module';
declare let jasmine: any; declare let jasmine: any;
describe('TagService', () => { describe('TagService', () => {
let service: TagService; let service: TagService;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [ContentTestingModule]
CoreModule.forRoot()
]
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService); service = TestBed.get(TagService);
service = new TagService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()), new LogService(new AppConfigService(null)));
}); });
beforeEach(() => { beforeEach(() => {

View File

@@ -21,7 +21,7 @@ import { AuthenticationService } from '../services/authentication.service';
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model'; import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
import { DiscoveryApiService } from '../services/discovery-api.service'; import { DiscoveryApiService } from '../services/discovery-api.service';
import { ObjectDataTableAdapter } from '../datatable/data/object-datatable-adapter'; import { ObjectDataTableAdapter } from '../datatable/data/object-datatable-adapter';
import { UserPreferencesService } from '../services/user-preferences.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
@Component({ @Component({
selector: 'adf-about', selector: 'adf-about',
@@ -44,7 +44,7 @@ export class AboutComponent implements OnInit {
bpmVersion: BpmProductVersionModel = null; bpmVersion: BpmProductVersionModel = null;
constructor(private http: Http, constructor(private http: Http,
private userPreference: UserPreferencesService, private appConfig: AppConfigService,
private authService: AuthenticationService, private authService: AuthenticationService,
private discovery: DiscoveryApiService) { private discovery: DiscoveryApiService) {
} }
@@ -114,8 +114,8 @@ export class AboutComponent implements OnInit {
}); });
this.ecmHost = this.userPreference.ecmHost; this.ecmHost = this.appConfig.get<string>(AppConfigValues.ECMHOST);
this.bpmHost = this.userPreference.bpmHost; this.bpmHost = this.appConfig.get<string>(AppConfigValues.BPMHOST);
} }
private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void { private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void {

View File

@@ -21,11 +21,24 @@ import { ObjectUtils } from '../utils/object-utils';
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export enum AppConfigValues {
APP_CONFIG_LANGUAGES_KEY = 'languages',
PROVIDERS = 'providers',
OAUTHCONFIG = 'oauth2',
ECMHOST = 'ecmHost',
BPMHOST = 'bpmHost',
AUTHTYPE = 'authType',
CONTEXTROOTECM = 'contextRootEcm',
CONTEXTROOTBPM = 'contextRootBpm',
ALFRESCO_REPOSITORY_NAME = 'alfrescoRepositoryName',
LOG_LEVEL = 'logLevel',
LOGIN_ROUTE = 'loginRoute',
DISABLECSRF = 'disableCSRF'
}
@Injectable() @Injectable()
export class AppConfigService { export class AppConfigService {
static APP_CONFIG_LANGUAGES_KEY = 'languages';
config: any = { config: any = {
application: { application: {
name: 'Alfresco ADF Application' name: 'Alfresco ADF Application'

View File

@@ -17,21 +17,21 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { AppConfigService, StorageService } from '@alfresco/adf-core'; import { StorageService } from '../services/storage.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
@Injectable() @Injectable()
export class DebugAppConfigService extends AppConfigService { export class DebugAppConfigService extends AppConfigService {
constructor(private storage: StorageService, http: HttpClient) { constructor(private storage: StorageService, http: HttpClient) {
super(http); super(http);
} }
/** @override */ /** @override */
get<T>(key: string, defaultValue?: T): T { get<T>(key: string, defaultValue?: T): T {
if (key === 'ecmHost' || key === 'bpmHost') { if (key === AppConfigValues.OAUTHCONFIG) {
return <T> (<any> this.storage.getItem(key) || super.get<T>(key)); return <T> (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
} else {
return <T> (<any> this.storage.getItem(key) || super.get<T>(key, defaultValue));
} }
return super.get<T>(key, defaultValue);
} }
} }

View File

@@ -16,6 +16,7 @@
*/ */
export * from './app-config.service'; export * from './app-config.service';
export * from './debug-app-config.service';
export * from './app-config.pipe'; export * from './app-config.pipe';
export * from './app-config.module'; export * from './app-config.module';

View File

@@ -273,10 +273,19 @@
"description": "BPM host", "description": "BPM host",
"type": "string" "type": "string"
}, },
"providers": {
"description": "This parameter can accept as value ECM BPM or ALL you can set it accordingly where you want log-in",
"type": "string",
"enum": [ "ECM", "BPM", "ALL"]
},
"contextRootBpm": { "contextRootBpm": {
"description": "The context root of the BPM host", "description": "The context root of the BPM host",
"type": "string" "type": "string"
}, },
"disableCSRF": {
"description": "The context root of the BPM host",
"type": "boolean"
},
"application": { "application": {
"description": "Application's global configuration", "description": "Application's global configuration",
"type": "object", "type": "object",
@@ -460,7 +469,8 @@
}, },
"authType": { "authType": {
"description": "Kind of authentication BASIC or OAUTH, default value BASIC", "description": "Kind of authentication BASIC or OAUTH, default value BASIC",
"type": "string" "type": "string",
"enum": [ "BASIC", "OAUTH" ]
}, },
"oauth2": { "oauth2": {
"description": "AUTH configuration parameters", "description": "AUTH configuration parameters",

View File

@@ -16,12 +16,11 @@
*/ */
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
import { fakeAsync, tick, TestBed } from '@angular/core/testing'; import { fakeAsync, tick } from '@angular/core/testing';
import { NodeFavoriteDirective } from './node-favorite.directive'; import { NodeFavoriteDirective } from './node-favorite.directive';
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock'; import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { StorageService } from '../services/storage.service'; import { StorageService } from '../services/storage.service';
import { UserPreferencesService } from '../services/user-preferences.service';
import { setupTestBed } from '../testing/setupTestBed'; import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
@@ -29,15 +28,13 @@ describe('NodeFavoriteDirective', () => {
let directive; let directive;
let alfrescoApiService; let alfrescoApiService;
let userPreferences;
setupTestBed({ setupTestBed({
imports: [CoreTestingModule] imports: [CoreTestingModule]
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService); alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService());
directive = new NodeFavoriteDirective( alfrescoApiService); directive = new NodeFavoriteDirective( alfrescoApiService);
}); });

View File

@@ -122,7 +122,6 @@
"BASIC": "Basic Auth", "BASIC": "Basic Auth",
"SSO": "SSO", "SSO": "SSO",
"IMPLICIT-FLOW": "implicitFlow", "IMPLICIT-FLOW": "implicitFlow",
"TYPE-AUTH": "Authentication type",
"PROVIDER": "Provider", "PROVIDER": "Provider",
"REQUIRED": "The field is required", "REQUIRED": "The field is required",
"CS_URL_ERROR": "Content Services address doesn't match the URL format", "CS_URL_ERROR": "Content Services address doesn't match the URL format",

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service'; import { UserPreferencesService } from '../services/user-preferences.service';
@Component({ @Component({
@@ -35,7 +35,7 @@ export class LanguageMenuComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
const languagesCongifApp = this.appConfig.get<Array<any>>(AppConfigService.APP_CONFIG_LANGUAGES_KEY); const languagesCongifApp = this.appConfig.get<Array<any>>(AppConfigValues.APP_CONFIG_LANGUAGES_KEY);
if (languagesCongifApp) { if (languagesCongifApp) {
this.languages = languagesCongifApp; this.languages = languagesCongifApp;
} }

View File

@@ -20,12 +20,14 @@ import { Validators } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { UserPreferencesService } from '../../services/user-preferences.service'; import { UserPreferencesService } from '../../services/user-preferences.service';
import { AppConfigService } from '../../app-config/app-config.service';
import { AuthenticationService } from '../../services/authentication.service'; import { AuthenticationService } from '../../services/authentication.service';
import { LoginErrorEvent } from '../models/login-error.event'; import { LoginErrorEvent } from '../models/login-error.event';
import { LoginSuccessEvent } from '../models/login-success.event'; import { LoginSuccessEvent } from '../models/login-success.event';
import { LoginComponent } from './login.component'; import { LoginComponent } from './login.component';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { OauthConfigModel } from '../../models/oauth-config.model'; import { OauthConfigModel } from '../../models/oauth-config.model';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { setupTestBed } from '../../testing/setupTestBed'; import { setupTestBed } from '../../testing/setupTestBed';
import { CoreTestingModule } from '../../testing/core.testing.module'; import { CoreTestingModule } from '../../testing/core.testing.module';
@@ -37,6 +39,8 @@ describe('LoginComponent', () => {
let authService: AuthenticationService; let authService: AuthenticationService;
let router: Router; let router: Router;
let userPreferences: UserPreferencesService; let userPreferences: UserPreferencesService;
let appConfigService: AppConfigService;
let alfrescoApiService: AlfrescoApiService;
let usernameInput, passwordInput; let usernameInput, passwordInput;
@@ -70,6 +74,8 @@ describe('LoginComponent', () => {
authService = TestBed.get(AuthenticationService); authService = TestBed.get(AuthenticationService);
router = TestBed.get(Router); router = TestBed.get(Router);
userPreferences = TestBed.get(UserPreferencesService); userPreferences = TestBed.get(UserPreferencesService);
appConfigService = TestBed.get(AppConfigService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
fixture.detectChanges(); fixture.detectChanges();
@@ -577,11 +583,9 @@ describe('LoginComponent', () => {
describe('SSO', () => { describe('SSO', () => {
beforeEach(() => { beforeEach(() => {
userPreferences.oauthConfig = <OauthConfigModel> { implicitFlow: true }; appConfigService.config.oauth2 = <OauthConfigModel> { implicitFlow: true };
}); appConfigService.load();
alfrescoApiService.reset();
afterEach(() => {
userPreferences.oauthConfig = null;
}); });
it('should not show login username and password if SSO implicit flow is active', async(() => { it('should not show login username and password if SSO implicit flow is active', async(() => {
@@ -590,29 +594,34 @@ describe('LoginComponent', () => {
component.ngOnInit(); component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(element.querySelector('#username')).toBeNull(); expect(element.querySelector('#username')).toBeNull();
expect(element.querySelector('#password')).toBeNull(); expect(element.querySelector('#password')).toBeNull();
});
})); }));
it('should not show the login base auth button', async(() => { it('should not show the login base auth button', async(() => {
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
userPreferences.oauthConfig = <OauthConfigModel> { implicitFlow: true };
component.ngOnInit(); component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => {
expect(element.querySelector('#login-button')).toBeNull(); expect(element.querySelector('#login-button')).toBeNull();
});
})); }));
it('should show the login SSO button', async(() => { it('should show the login SSO button', async(() => {
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
userPreferences.oauthConfig = <OauthConfigModel> { implicitFlow: true };
component.ngOnInit(); component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => {
expect(element.querySelector('#login-button-sso')).toBeDefined(); expect(element.querySelector('#login-button-sso')).toBeDefined();
});
})); }));
}); });

View File

@@ -15,9 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { Component, ElementRef, EventEmitter,
Component, ElementRef, EventEmitter, Input, OnInit, Input, OnInit, Output, TemplateRef, ViewEncapsulation
Output, TemplateRef, ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@@ -30,6 +29,11 @@ import { UserPreferencesService } from '../../services/user-preferences.service'
import { LoginErrorEvent } from '../models/login-error.event'; import { LoginErrorEvent } from '../models/login-error.event';
import { LoginSubmitEvent } from '../models/login-submit.event'; import { LoginSubmitEvent } from '../models/login-submit.event';
import { LoginSuccessEvent } from '../models/login-success.event'; import { LoginSuccessEvent } from '../models/login-success.event';
import {
AppConfigService,
AppConfigValues
} from '../../app-config/app-config.service';
import { OauthConfigModel } from '../../models/oauth-config.model';
enum LoginSteps { enum LoginSteps {
Landing = 0, Landing = 0,
@@ -43,12 +47,11 @@ enum LoginSteps {
styleUrls: ['./login.component.scss'], styleUrls: ['./login.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { host: {
'class': 'adf-login', class: 'adf-login',
'(blur)': 'onBlur($event)' '(blur)': 'onBlur($event)'
} }
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
isPasswordShow: boolean = false; isPasswordShow: boolean = false;
/** /**
@@ -136,25 +139,29 @@ export class LoginComponent implements OnInit {
* @param authService * @param authService
* @param translate * @param translate
*/ */
constructor(private _fb: FormBuilder, constructor(
private _fb: FormBuilder,
private authService: AuthenticationService, private authService: AuthenticationService,
private translateService: TranslationService, private translateService: TranslationService,
private logService: LogService, private logService: LogService,
private elementRef: ElementRef, private elementRef: ElementRef,
private router: Router, private router: Router,
private userPreferences: UserPreferencesService) { private appConfig: AppConfigService,
private userPreferences: UserPreferencesService
) {
this.initFormError(); this.initFormError();
this.initFormFieldsMessages(); this.initFormFieldsMessages();
} }
ngOnInit() { ngOnInit() {
if (this.authService.isOauth()) { if (this.authService.isOauth()) {
if (this.userPreferences.oauthConfig && this.userPreferences.oauthConfig.implicitFlow) { let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
if (oauth && oauth.implicitFlow) {
this.implicitFlow = true; this.implicitFlow = true;
} }
} }
if (this.hasCustomFiledsValidation()) { if (this.hasCustomFieldsValidation()) {
this.form = this._fb.group(this.fieldsValidation); this.form = this._fb.group(this.fieldsValidation);
} else { } else {
this.initFormFieldsDefault(); this.initFormFieldsDefault();
@@ -170,11 +177,13 @@ export class LoginComponent implements OnInit {
*/ */
onSubmit(values: any) { onSubmit(values: any) {
if (this.disableCsrf !== null && this.disableCsrf !== undefined) { if (this.disableCsrf !== null && this.disableCsrf !== undefined) {
this.userPreferences.disableCSRF = this.disableCsrf; this.appConfig.get<boolean>(AppConfigValues.DISABLECSRF);
} }
this.disableError(); this.disableError();
const args = new LoginSubmitEvent({ controls: { username: this.form.controls.username } }); const args = new LoginSubmitEvent({
controls: { username: this.form.controls.username }
});
this.executeSubmit.emit(args); this.executeSubmit.emit(args);
if (args.defaultPrevented) { if (args.defaultPrevented) {
@@ -185,7 +194,7 @@ export class LoginComponent implements OnInit {
} }
implicitLogin() { implicitLogin() {
this.authService.ssoImplictiLogin(); this.authService.ssoImplicitLogin();
} }
/** /**
@@ -197,12 +206,15 @@ export class LoginComponent implements OnInit {
for (let field in this.formError) { for (let field in this.formError) {
if (field) { if (field) {
this.formError[field] = ''; this.formError[field] = '';
let hasError = (this.form.controls[field].errors && data[field] !== '') || let hasError =
(this.form.controls[field].dirty && !this.form.controls[field].valid); (this.form.controls[field].errors && data[field] !== '') ||
(this.form.controls[field].dirty &&
!this.form.controls[field].valid);
if (hasError) { if (hasError) {
for (let key in this.form.controls[field].errors) { for (let key in this.form.controls[field].errors) {
if (key) { if (key) {
this.formError[field] += this._message[field][key] + ''; this.formError[field] +=
this._message[field][key] + '';
} }
} }
} }
@@ -216,15 +228,20 @@ export class LoginComponent implements OnInit {
*/ */
private performLogin(values: any) { private performLogin(values: any) {
this.actualLoginStep = LoginSteps.Checking; this.actualLoginStep = LoginSteps.Checking;
this.authService.login(values.username, values.password, this.rememberMe) this.authService
.login(values.username, values.password, this.rememberMe)
.subscribe( .subscribe(
(token: any) => { (token: any) => {
const redirectUrl = this.authService.getRedirect(this.providers); const redirectUrl = this.authService.getRedirect(
this.providers
);
this.actualLoginStep = LoginSteps.Welcome; this.actualLoginStep = LoginSteps.Welcome;
this.userPreferences.setStoragePrefix(values.username); this.userPreferences.setStoragePrefix(values.username);
values.password = null; values.password = null;
this.success.emit(new LoginSuccessEvent(token, values.username, null)); this.success.emit(
new LoginSuccessEvent(token, values.username, null)
);
if (redirectUrl) { if (redirectUrl) {
this.authService.setRedirect(null); this.authService.setRedirect(null);
@@ -247,16 +264,25 @@ export class LoginComponent implements OnInit {
* Check and display the right error message in the UI * Check and display the right error message in the UI
*/ */
private displayErrorMessage(err: any): void { private displayErrorMessage(err: any): void {
if (
if (err.error && err.error.crossDomain && err.error.message.indexOf('Access-Control-Allow-Origin') !== -1) { err.error &&
err.error.crossDomain &&
err.error.message.indexOf('Access-Control-Allow-Origin') !== -1
) {
this.errorMsg = err.error.message; this.errorMsg = err.error.message;
} else if (err.status === 403 && err.message.indexOf('Invalid CSRF-token') !== -1) { } else if (
err.status === 403 &&
err.message.indexOf('Invalid CSRF-token') !== -1
) {
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CSRF'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CSRF';
} else if (err.status === 403 && err.message.indexOf('The system is currently in read-only mode') !== -1) { } else if (
err.status === 403 &&
err.message.indexOf('The system is currently in read-only mode') !==
-1
) {
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ECM-LICENSE'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ECM-LICENSE';
} else { } else {
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS';
} }
} }
@@ -275,7 +301,12 @@ export class LoginComponent implements OnInit {
* @param ruleId - i.e. required | minlength | maxlength * @param ruleId - i.e. required | minlength | maxlength
* @param msg * @param msg
*/ */
addCustomValidationError(field: string, ruleId: string, msg: string, params?: any) { addCustomValidationError(
field: string,
ruleId: string,
msg: string,
params?: any
) {
if (params) { if (params) {
this.translateService.get(msg, params).subscribe((res: string) => { this.translateService.get(msg, params).subscribe((res: string) => {
this._message[field][ruleId] = res; this._message[field][ruleId] = res;
@@ -290,7 +321,10 @@ export class LoginComponent implements OnInit {
*/ */
toggleShowPassword() { toggleShowPassword() {
this.isPasswordShow = !this.isPasswordShow; this.isPasswordShow = !this.isPasswordShow;
this.elementRef.nativeElement.querySelector('#password').type = this.isPasswordShow ? 'text' : 'password'; this.elementRef.nativeElement.querySelector('#password').type = this
.isPasswordShow
? 'text'
: 'password';
} }
/** /**
@@ -313,8 +347,8 @@ export class LoginComponent implements OnInit {
*/ */
private initFormError() { private initFormError() {
this.formError = { this.formError = {
'username': '', username: '',
'password': '' password: ''
}; };
} }
@@ -323,8 +357,8 @@ export class LoginComponent implements OnInit {
*/ */
private initFormFieldsMessages() { private initFormFieldsMessages() {
this._message = { this._message = {
'username': {}, username: {},
'password': {} password: {}
}; };
} }
@@ -333,15 +367,17 @@ export class LoginComponent implements OnInit {
*/ */
private initFormFieldsMessagesDefault() { private initFormFieldsMessagesDefault() {
this._message = { this._message = {
'username': { username: {
'required': 'LOGIN.MESSAGES.USERNAME-REQUIRED' required: 'LOGIN.MESSAGES.USERNAME-REQUIRED'
}, },
'password': { password: {
'required': 'LOGIN.MESSAGES.PASSWORD-REQUIRED' required: 'LOGIN.MESSAGES.PASSWORD-REQUIRED'
} }
}; };
this.translateService.get('LOGIN.MESSAGES.USERNAME-MIN', { minLength: this.minLength }).subscribe((res: string) => { this.translateService
.get('LOGIN.MESSAGES.USERNAME-MIN', { minLength: this.minLength })
.subscribe((res: string) => {
this._message['username']['minlength'] = res; this._message['username']['minlength'] = res;
}); });
} }
@@ -368,7 +404,7 @@ export class LoginComponent implements OnInit {
this.isError = true; this.isError = true;
} }
private hasCustomFiledsValidation(): boolean { private hasCustomFieldsValidation(): boolean {
return this.fieldsValidation !== undefined; return this.fieldsValidation !== undefined;
} }
} }

View File

@@ -19,16 +19,14 @@ import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { StorageService } from '../services/storage.service'; import { StorageService } from '../services/storage.service';
import { AlfrescoApiService } from '../services/alfresco-api.service'; import { AlfrescoApiService } from '../services/alfresco-api.service';
import { UserPreferencesService } from '../services/user-preferences.service';
/* tslint:disable:adf-file-name */ /* tslint:disable:adf-file-name */
@Injectable() @Injectable()
export class AlfrescoApiServiceMock extends AlfrescoApiService { export class AlfrescoApiServiceMock extends AlfrescoApiService {
constructor(protected appConfig: AppConfigService, constructor(protected appConfig: AppConfigService,
protected userPreference: UserPreferencesService,
protected storage: StorageService) { protected storage: StorageService) {
super(appConfig, userPreference, storage); super(appConfig, storage);
if (!this.alfrescoApi) { if (!this.alfrescoApi) {
this.initAlfrescoApi(); this.initAlfrescoApi();
} }

View File

@@ -18,7 +18,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@Injectable() @Injectable()
export class AppConfigServiceMock extends AppConfigService { export class AppConfigServiceMock extends AppConfigService {

View File

@@ -17,22 +17,30 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
AlfrescoApi, ContentApi, FavoritesApi, NodesApi, AlfrescoApi,
PeopleApi, RenditionsApi, SharedlinksApi, SitesApi, ContentApi,
VersionsApi, ClassesApi, SearchApi, GroupsApi, MinimalNodeEntryEntity FavoritesApi,
NodesApi,
PeopleApi,
RenditionsApi,
SharedlinksApi,
SitesApi,
VersionsApi,
ClassesApi,
SearchApi,
GroupsApi,
MinimalNodeEntryEntity
} from 'alfresco-js-api'; } from 'alfresco-js-api';
import * as alfrescoApi from 'alfresco-js-api'; import * as alfrescoApi from 'alfresco-js-api';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { Subject } from 'rxjs/Subject'; import { Subject } from 'rxjs/Subject';
import { UserPreferencesService, UserPreferenceValues } from './user-preferences.service'; import { OauthConfigModel } from '../models/oauth-config.model';
import { merge } from 'rxjs/observable/merge';
/* tslint:disable:adf-file-name */ /* tslint:disable:adf-file-name */
@Injectable() @Injectable()
export class AlfrescoApiService { export class AlfrescoApiService {
/** /**
* Publish/subscribe to events related to node updates. * Publish/subscribe to events related to node updates.
*/ */
@@ -96,19 +104,7 @@ export class AlfrescoApiService {
return this.getInstance().core.groupsApi; return this.getInstance().core.groupsApi;
} }
constructor(protected appConfig: AppConfigService, constructor(protected appConfig: AppConfigService, protected storage: StorageService) {}
protected userPreferencesService: UserPreferencesService,
protected storage: StorageService) {
merge(this.userPreferencesService.select(UserPreferenceValues.oauthConfig),
this.userPreferencesService.select(UserPreferenceValues.ecmHost),
this.userPreferencesService.select(UserPreferenceValues.bpmHost),
this.userPreferencesService.select(UserPreferenceValues.authType),
this.userPreferencesService.select(UserPreferenceValues.providers)).subscribe(() => {
this.reset();
});
}
async load() { async load() {
await this.appConfig.load().then(() => { await this.appConfig.load().then(() => {
@@ -121,21 +117,22 @@ export class AlfrescoApiService {
} }
protected initAlfrescoApi() { protected initAlfrescoApi() {
let oauth; let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
if (this.userPreferencesService.oauthConfig) {
oauth = Object.assign({}, this.userPreferencesService.oauthConfig); if (oauth) {
oauth.redirectUri = window.location.origin + (oauth.redirectUri || '/'); oauth.redirectUri = window.location.origin + (oauth.redirectUri || '/');
oauth.redirectUriLogout = window.location.origin + (oauth.redirectUriLogout || '/'); oauth.redirectUriLogout = window.location.origin + (oauth.redirectUriLogout || '/');
} }
const config = { const config = {
provider: this.userPreferencesService.providers, provider: this.appConfig.get<string>(AppConfigValues.PROVIDERS),
ticketEcm: this.storage.getItem('ticket-ECM'), ticketEcm: this.storage.getItem('ticket-ECM'),
ticketBpm: this.storage.getItem('ticket-BPM'), ticketBpm: this.storage.getItem('ticket-BPM'),
hostEcm: this.userPreferencesService.ecmHost, hostEcm: this.appConfig.get<string>(AppConfigValues.ECMHOST),
hostBpm: this.userPreferencesService.bpmHost, hostBpm: this.appConfig.get<string>(AppConfigValues.BPMHOST),
authType: this.userPreferencesService.authType, authType: this.appConfig.get<string>(AppConfigValues.AUTHTYPE),
contextRootBpm: this.appConfig.get<string>('contextRootBpm'), contextRootBpm: this.appConfig.get<string>(AppConfigValues.CONTEXTROOTBPM),
contextRoot: this.appConfig.get<string>('contextRootEcm'), contextRoot: this.appConfig.get<string>(AppConfigValues.CONTEXTROOTECM),
disableCsrf: this.storage.getItem('DISABLE_CSRF') === 'true', disableCsrf: this.storage.getItem('DISABLE_CSRF') === 'true',
oauth2: oauth oauth2: oauth
}; };

View File

@@ -16,20 +16,14 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot, Router } from '@angular/router';
ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot, import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
Router
} from '@angular/router';
import { AppConfigService } from '../app-config/app-config.service';
import { AuthenticationService } from './authentication.service'; import { AuthenticationService } from './authentication.service';
import { UserPreferencesService } from './user-preferences.service'; import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable() @Injectable()
export class AuthGuardBpm implements CanActivate, CanActivateChild { export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService, constructor(private authService: AuthenticationService, private router: Router, private appConfig: AppConfigService) {}
private router: Router,
private userPreference: UserPreferencesService,
private appConfig: AppConfigService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkLogin(state.url); return this.checkLogin(state.url);
@@ -54,12 +48,11 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
} }
isOAuthWithoutSilentLogin() { isOAuthWithoutSilentLogin() {
return this.authService.isOauth() && this.userPreference.oauthConfig.silentLogin === false; let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
return this.authService.isOauth() && oauth.silentLogin === false;
} }
private getRouteDestinationForLogin(): string { private getRouteDestinationForLogin(): string {
return this.appConfig && return this.appConfig && this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
this.appConfig.get<string>('loginRoute') ?
this.appConfig.get<string>('loginRoute') : 'login';
} }
} }

View File

@@ -20,12 +20,12 @@ import {
ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router
} from '@angular/router'; } from '@angular/router';
import { AuthenticationService } from './authentication.service'; import { AuthenticationService } from './authentication.service';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable() @Injectable()
export class AuthGuardEcm implements CanActivate { export class AuthGuardEcm implements CanActivate {
constructor( constructor(private authService: AuthenticationService,
private authService: AuthenticationService,
private router: Router, private router: Router,
private appConfig: AppConfigService) { private appConfig: AppConfigService) {
} }
@@ -43,16 +43,23 @@ export class AuthGuardEcm implements CanActivate {
return true; return true;
} }
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin()) {
this.authService.setRedirect({ provider: 'ECM', url: redirectUrl }); this.authService.setRedirect({ provider: 'ECM', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin(); const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]); this.router.navigate(['/' + pathToLogin]);
}
return false; return false;
} }
isOAuthWithoutSilentLogin() {
let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
return this.authService.isOauth() && oauth.silentLogin === false;
}
private getRouteDestinationForLogin(): string { private getRouteDestinationForLogin(): string {
return this.appConfig && return this.appConfig &&
this.appConfig.get<string>('loginRoute') ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ?
this.appConfig.get<string>('loginRoute') : 'login'; this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
} }
} }

View File

@@ -22,15 +22,15 @@ import {
} from '@angular/router'; } from '@angular/router';
import { AuthenticationService } from './authentication.service'; import { AuthenticationService } from './authentication.service';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { UserPreferencesService } from './user-preferences.service'; import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable() @Injectable()
export class AuthGuard implements CanActivate, CanActivateChild { export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService, constructor(private authService: AuthenticationService,
private router: Router, private router: Router,
private userPreference: UserPreferencesService, private appConfig: AppConfigService) {
private appConfig: AppConfigService) {} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> {
const redirectUrl = state.url; const redirectUrl = state.url;
@@ -56,12 +56,13 @@ export class AuthGuard implements CanActivate, CanActivateChild {
} }
isOAuthWithoutSilentLogin() { isOAuthWithoutSilentLogin() {
return this.authService.isOauth() && this.userPreference.oauthConfig.silentLogin === false; let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
return this.authService.isOauth() && oauth.silentLogin === false;
} }
public getRouteDestinationForLogin(): string { public getRouteDestinationForLogin(): string {
return this.appConfig && return this.appConfig &&
this.appConfig.get<string>('loginRoute') ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ?
this.appConfig.get<string>('loginRoute') : 'login'; this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
} }
} }

View File

@@ -20,7 +20,7 @@ import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service'; import { AuthenticationService } from './authentication.service';
import { CookieService } from './cookie.service'; import { CookieService } from './cookie.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { UserPreferencesService } from './user-preferences.service'; import { AppConfigService } from '../app-config/app-config.service';
import { setupTestBed } from '../testing/setupTestBed'; import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
@@ -29,7 +29,7 @@ declare let jasmine: any;
describe('AuthenticationService', () => { describe('AuthenticationService', () => {
let apiService: AlfrescoApiService; let apiService: AlfrescoApiService;
let authService: AuthenticationService; let authService: AuthenticationService;
let preferences: UserPreferencesService; let appConfigService: AppConfigService;
let storage: StorageService; let storage: StorageService;
let cookie: CookieService; let cookie: CookieService;
@@ -40,7 +40,6 @@ describe('AuthenticationService', () => {
beforeEach(() => { beforeEach(() => {
apiService = TestBed.get(AlfrescoApiService); apiService = TestBed.get(AlfrescoApiService);
authService = TestBed.get(AuthenticationService); authService = TestBed.get(AuthenticationService);
preferences = TestBed.get(UserPreferencesService);
cookie = TestBed.get(CookieService); cookie = TestBed.get(CookieService);
cookie.clear(); cookie.clear();
@@ -60,7 +59,9 @@ describe('AuthenticationService', () => {
describe('remember me', () => { describe('remember me', () => {
beforeEach(() => { beforeEach(() => {
preferences.providers = 'ECM'; appConfigService = TestBed.get(AppConfigService);
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset(); apiService.reset();
}); });
@@ -124,7 +125,8 @@ describe('AuthenticationService', () => {
describe('when the setting is ECM', () => { describe('when the setting is ECM', () => {
beforeEach(() => { beforeEach(() => {
preferences.providers = 'ECM'; appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset(); apiService.reset();
}); });
@@ -276,26 +278,27 @@ describe('AuthenticationService', () => {
it('[ECM] should set/get redirectUrl when provider is ECM', () => { it('[ECM] should set/get redirectUrl when provider is ECM', () => {
authService.setRedirect({ provider: 'ECM', url: 'some-url' }); authService.setRedirect({ provider: 'ECM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toEqual('some-url'); expect(authService.getRedirect(appConfigService.config.providers)).toEqual('some-url');
}); });
it('[ECM] should set/get redirectUrl when provider is BPM', () => { it('[ECM] should set/get redirectUrl when provider is BPM', () => {
authService.setRedirect({ provider: 'BPM', url: 'some-url' }); authService.setRedirect({ provider: 'BPM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toBeNull(); expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
}); });
it('[ECM] should return null as redirectUrl when redirectUrl field is not set', () => { it('[ECM] should return null as redirectUrl when redirectUrl field is not set', () => {
authService.setRedirect(null); authService.setRedirect(null);
expect(authService.getRedirect(preferences.providers)).toBeNull(); expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
}); });
}); });
describe('when the setting is BPM', () => { describe('when the setting is BPM', () => {
beforeEach(() => { beforeEach(() => {
preferences.providers = 'BPM'; appConfigService.config.providers = 'BPM';
appConfigService.load();
apiService.reset(); apiService.reset();
}); });
@@ -429,26 +432,27 @@ describe('AuthenticationService', () => {
it('[BPM] should set/get redirectUrl when provider is BPM', () => { it('[BPM] should set/get redirectUrl when provider is BPM', () => {
authService.setRedirect({ provider: 'BPM', url: 'some-url' }); authService.setRedirect({ provider: 'BPM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toEqual('some-url'); expect(authService.getRedirect(appConfigService.config.providers)).toEqual('some-url');
}); });
it('[BPM] should set/get redirectUrl when provider is ECM', () => { it('[BPM] should set/get redirectUrl when provider is ECM', () => {
authService.setRedirect({ provider: 'ECM', url: 'some-url' }); authService.setRedirect({ provider: 'ECM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toBeNull(); expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
}); });
it('[BPM] should return null as redirectUrl when redirectUrl field is not set', () => { it('[BPM] should return null as redirectUrl when redirectUrl field is not set', () => {
authService.setRedirect(null); authService.setRedirect(null);
expect(authService.getRedirect(preferences.providers)).toBeNull(); expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
}); });
}); });
describe('when the setting is both ECM and BPM ', () => { describe('when the setting is both ECM and BPM ', () => {
beforeEach(() => { beforeEach(() => {
preferences.providers = 'ALL'; appConfigService.config.providers = 'ALL';
appConfigService.load();
apiService.reset(); apiService.reset();
}); });
@@ -546,25 +550,25 @@ describe('AuthenticationService', () => {
it('[ALL] should set/get redirectUrl when provider is ALL', () => { it('[ALL] should set/get redirectUrl when provider is ALL', () => {
authService.setRedirect({ provider: 'ALL', url: 'some-url' }); authService.setRedirect({ provider: 'ALL', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toEqual('some-url'); expect(authService.getRedirect(appConfigService.config.providers)).toEqual('some-url');
}); });
it('[ALL] should set/get redirectUrl when provider is BPM', () => { it('[ALL] should set/get redirectUrl when provider is BPM', () => {
authService.setRedirect({ provider: 'BPM', url: 'some-url' }); authService.setRedirect({ provider: 'BPM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toEqual('some-url'); expect(authService.getRedirect(appConfigService.config.providers)).toEqual('some-url');
}); });
it('[ALL] should set/get redirectUrl when provider is ECM', () => { it('[ALL] should set/get redirectUrl when provider is ECM', () => {
authService.setRedirect({ provider: 'ECM', url: 'some-url' }); authService.setRedirect({ provider: 'ECM', url: 'some-url' });
expect(authService.getRedirect(preferences.providers)).toEqual('some-url'); expect(authService.getRedirect(appConfigService.config.providers)).toEqual('some-url');
}); });
it('[ALL] should return null as redirectUrl when redirectUrl field is not set', () => { it('[ALL] should return null as redirectUrl when redirectUrl field is not set', () => {
authService.setRedirect(null); authService.setRedirect(null);
expect(authService.getRedirect(preferences.providers)).toBeNull(); expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
}); });
}); });

View File

@@ -22,11 +22,11 @@ import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from './cookie.service'; import { CookieService } from './cookie.service';
import { LogService } from './log.service'; import { LogService } from './log.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { UserPreferencesService } from './user-preferences.service';
import 'rxjs/add/observable/fromPromise'; import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw'; import 'rxjs/add/observable/throw';
import { RedirectionModel } from '../models/redirection.model'; import { RedirectionModel } from '../models/redirection.model';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME'; const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30 ; const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30 ;
@@ -39,7 +39,7 @@ export class AuthenticationService {
onLogout: Subject<any> = new Subject<any>(); onLogout: Subject<any> = new Subject<any>();
constructor( constructor(
private preferences: UserPreferencesService, private appConfig: AppConfigService,
private alfrescoApi: AlfrescoApiService, private alfrescoApi: AlfrescoApiService,
private storage: StorageService, private storage: StorageService,
private cookie: CookieService, private cookie: CookieService,
@@ -73,7 +73,7 @@ export class AuthenticationService {
this.saveTickets(); this.saveTickets();
this.onLogin.next(response); this.onLogin.next(response);
return { return {
type: this.preferences.providers, type: this.appConfig.get(AppConfigValues.PROVIDERS),
ticket: response ticket: response
}; };
}) })
@@ -83,7 +83,7 @@ export class AuthenticationService {
/** /**
* Logs the user in with SSO * Logs the user in with SSO
*/ */
ssoImplictiLogin() { ssoImplicitLogin() {
this.alfrescoApi.getInstance().implicitLogin(); this.alfrescoApi.getInstance().implicitLogin();
} }

View File

@@ -18,7 +18,7 @@
/* tslint:disable:no-console */ /* tslint:disable:no-console */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { logLevels, LogLevelsEnum } from '../models/log-levels.model'; import { logLevels, LogLevelsEnum } from '../models/log-levels.model';
import { Subject } from 'rxjs/Subject'; import { Subject } from 'rxjs/Subject';
@@ -26,7 +26,7 @@ import { Subject } from 'rxjs/Subject';
export class LogService { export class LogService {
get currentLogLevel() { get currentLogLevel() {
let configLevel: string = this.appConfig.get<string>('logLevel'); let configLevel: string = this.appConfig.get<string>(AppConfigValues.LOG_LEVEL);
if (configLevel) { if (configLevel) {
return this.getLogLevel(configLevel); return this.getLogLevel(configLevel);

View File

@@ -15,115 +15,64 @@
* limitations under the License. * limitations under the License.
*/ */
import { inject, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { Title } from '@angular/platform-browser'; import { setupTestBed } from '../testing/setupTestBed';
import { Observable } from 'rxjs/Observable'; import { CoreModule } from '../core.module';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { PageTitleService } from './page-title.service'; import { PageTitleService } from './page-title.service';
import { CoreTestingModule } from '../testing/core.testing.module';
import { TranslationService } from './translation.service'; import { TranslationService } from './translation.service';
import { TranslationMock } from '../mock/translation.service.mock'; import { Title } from '@angular/platform-browser';
class TestConfig { describe('AppTitle service', () => {
private setup: any = {
applicationName: undefined
};
titleService: Title = null; let titleService: any;
appTitleService: PageTitleService = null; let translationService: any;
translationService: TranslationService; let pageTitleService: any;
let appConfigService: any;
let titleServiceSpy: any;
constructor(setup: any = {}) { setupTestBed({
Object.assign(this.setup, setup);
const titleServiceProvider = {
provide: Title,
useValue: {
setTitle: jasmine.createSpy('setTitleSpy')
}
};
const appConfigProvider = {
provide: AppConfigService,
useValue: {
config: {
application: {
name: this.setup.applicationName
}
},
get: () => this.setup.applicationName,
load: () => {
return Promise.resolve();
},
onLoad: Observable.of({})
}
};
TestBed.configureTestingModule({
imports: [ imports: [
CoreTestingModule CoreModule.forRoot()
],
providers: [
titleServiceProvider,
appConfigProvider,
PageTitleService,
{
provide: TranslationService,
useClass: TranslationMock
}
] ]
}); });
inject([Title, PageTitleService, TranslationService], (titleService, appTitleService, translationService) => { beforeEach(() => {
this.titleService = titleService; titleService = TestBed.get(Title);
this.appTitleService = appTitleService; pageTitleService = TestBed.get(PageTitleService);
this.translationService = translationService; translationService = TestBed.get(TranslationService);
})(); appConfigService = TestBed.get(AppConfigService);
}
}
describe('AppTitle service', () => { titleServiceSpy = spyOn(titleService, 'setTitle').and.callThrough();
it('should set default application name', () => {
const { appTitleService, titleService } = new TestConfig({ appConfigService.config.application.name = 'My application';
applicationName: undefined
}); });
appTitleService.setTitle(); it('should set default application name', () => {
expect(titleService.setTitle).toHaveBeenCalledWith('Alfresco ADF Application'); appConfigService.config.application = {};
pageTitleService.setTitle();
expect(titleServiceSpy).toHaveBeenCalledWith('Alfresco ADF Application');
}); });
it('should set only the application name', () => { it('should set only the application name', () => {
const { appTitleService, titleService } = new TestConfig({ pageTitleService.setTitle();
applicationName: 'My application' expect(titleServiceSpy).toHaveBeenCalledWith('My application');
});
appTitleService.setTitle();
expect(titleService.setTitle).toHaveBeenCalledWith('My application');
}); });
it('should append application name to the title', () => { it('should append application name to the title', () => {
const { appTitleService, titleService } = new TestConfig({ pageTitleService.setTitle('My page');
applicationName: 'My application' expect(titleServiceSpy).toHaveBeenCalledWith('My page - My application');
});
appTitleService.setTitle('My page');
expect(titleService.setTitle).toHaveBeenCalledWith('My page - My application');
}); });
it('should update title on language change', () => { it('should update title on language change', () => {
const { appTitleService, titleService, translationService } = new TestConfig({
applicationName: 'My application'
});
spyOn(translationService, 'instant').and.returnValues('hello', 'привет'); spyOn(translationService, 'instant').and.returnValues('hello', 'привет');
appTitleService.setTitle('key'); pageTitleService.setTitle('key');
expect(titleService.setTitle).toHaveBeenCalledWith('hello - My application'); expect(titleServiceSpy).toHaveBeenCalledWith('hello - My application');
(<any> titleService).setTitle.calls.reset(); (<any> titleService).setTitle.calls.reset();
translationService.translate.onLangChange.next(<any> {}); translationService.translate.onLangChange.next(<any> {});
expect(titleService.setTitle).toHaveBeenCalledWith('привет - My application'); expect(titleServiceSpy).toHaveBeenCalledWith('привет - My application');
}); });
}); });

View File

@@ -16,29 +16,25 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { LogService } from './log.service'; import { LogService } from './log.service';
import { UserPreferencesService } from './user-preferences.service';
@Injectable() @Injectable()
export class SettingsService { export class SettingsService {
constructor( constructor(private appConfig: AppConfigService,
private appConfig: AppConfigService, private logService: LogService) {
private logService: LogService,
private preferences: UserPreferencesService) {
} }
/** @deprecated in 1.6.0 */ /** @deprecated in 1.6.0 */
public get ecmHost(): string { public get ecmHost(): string {
this.logService.log('SettingsService.ecmHost is deprecated. Use AppConfigService instead.'); this.logService.log('SettingsService.ecmHost is deprecated. Use AppConfigService instead.');
return this.appConfig.get<string>('ecmHost'); return this.appConfig.get<string>(AppConfigValues.ECMHOST);
} }
/** @deprecated in 1.7.0 */ /** @deprecated in 1.7.0 */
public set csrfDisabled(csrfDisabled: boolean) { public set csrfDisabled(csrfDisabled: boolean) {
this.logService.log(`SettingsService.csrfDisabled is deprecated. Use UserPreferencesService.disableCSRF instead.`); this.logService.log(`SettingsService.csrfDisabled is deprecated. Use UserPreferencesService.disableCSRF instead.`);
this.preferences.disableCSRF = csrfDisabled;
} }
/** @deprecated in 1.6.0 */ /** @deprecated in 1.6.0 */
@@ -49,7 +45,7 @@ export class SettingsService {
/** @deprecated in 1.6.0 */ /** @deprecated in 1.6.0 */
public get bpmHost(): string { public get bpmHost(): string {
this.logService.log('SettingsService.bpmHost is deprecated. Use AppConfigService instead.'); this.logService.log('SettingsService.bpmHost is deprecated. Use AppConfigService instead.');
return this.appConfig.get<string>('bpmHost'); return this.appConfig.get<string>(AppConfigValues.BPMHOST);
} }
/** @deprecated in 1.6.0 */ /** @deprecated in 1.6.0 */
@@ -66,12 +62,11 @@ export class SettingsService {
/** @deprecated in 1.7.0 */ /** @deprecated in 1.7.0 */
public getProviders(): string { public getProviders(): string {
this.logService.log(`SettingsService.getProviders is deprecated. Use UserPreferencesService.authType instead.`); this.logService.log(`SettingsService.getProviders is deprecated. Use UserPreferencesService.authType instead.`);
return this.preferences.providers; return this.appConfig.get<string>(AppConfigValues.PROVIDERS);
} }
/** @deprecated in 1.7.0 */ /** @deprecated in 1.7.0 */
public setProviders(providers: string) { public setProviders(providers: string) {
this.logService.log(`SettingsService.getProviders is deprecated. Use UserPreferencesService.authType instead.`); this.logService.log(`SettingsService.aetProviders is deprecated. Use the app-config.json`);
this.preferences.providers = providers;
} }
} }

View File

@@ -20,7 +20,6 @@ import { TranslateService } from '@ngx-translate/core';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { UserPreferencesService } from './user-preferences.service'; import { UserPreferencesService } from './user-preferences.service';
import { UserPreferenceValues } from './user-preferences.service';
import { setupTestBed } from '../testing/setupTestBed'; import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
@@ -154,13 +153,4 @@ describe('UserPreferencesService', () => {
done(); done();
}); });
}); });
it('should stream only the selected attribute changes when using select', (done) => {
preferences.disableCSRF = false;
preferences.select(UserPreferenceValues.DisableCSRF).subscribe((disableCSRFFlag) => {
expect(disableCSRFFlag).toBeFalsy();
done();
});
});
}); });

View File

@@ -22,18 +22,11 @@ import { Observable } from 'rxjs/Observable';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import 'rxjs/add/operator/distinctUntilChanged'; import 'rxjs/add/operator/distinctUntilChanged';
import { OauthConfigModel } from '../models/oauth-config.model';
export enum UserPreferenceValues { export enum UserPreferenceValues {
PaginationSize = 'PAGINATION_SIZE', PaginationSize = 'PAGINATION_SIZE',
DisableCSRF = 'DISABLE_CSRF',
Locale = 'LOCALE', Locale = 'LOCALE',
SupportedPageSizes = 'supportedPageSizes', SupportedPageSizes = 'supportedPageSizes'
oauthConfig = 'oauthConfig',
ecmHost = 'ecmHost',
bpmHost = 'bpmHost',
providers = 'providers',
authType = 'authType'
} }
@Injectable() @Injectable()
@@ -45,11 +38,7 @@ export class UserPreferencesService {
locale: 'en' locale: 'en'
}; };
private userPreferenceStatus: any = { private userPreferenceStatus: any = this.defaults;
paginationSize: 25,
supportedPageSizes: [5, 10, 15, 20],
LOCALE: 'en'
};
/** /**
* @deprecated we are grouping every value changed on the user preference in a single stream : userPreferenceValue$ * @deprecated we are grouping every value changed on the user preference in a single stream : userPreferenceValue$
@@ -75,7 +64,6 @@ export class UserPreferencesService {
this.userPreferenceStatus[UserPreferenceValues.PaginationSize] = this.paginationSize ? this.userPreferenceStatus[UserPreferenceValues.PaginationSize] = this.paginationSize ?
this.paginationSize : this.appConfig.get('pagination.size', this.defaults.paginationSize); this.paginationSize : this.appConfig.get('pagination.size', this.defaults.paginationSize);
this.userPreferenceStatus[UserPreferenceValues.SupportedPageSizes] = this.appConfig.get('pagination.supportedPageSizes', this.defaults.supportedPageSizes); this.userPreferenceStatus[UserPreferenceValues.SupportedPageSizes] = this.appConfig.get('pagination.supportedPageSizes', this.defaults.supportedPageSizes);
this.userPreferenceStatus[UserPreferenceValues.DisableCSRF] = this.disableCSRF;
} }
/** /**
@@ -119,6 +107,19 @@ export class UserPreferencesService {
this.onChangeSubject.next(this.userPreferenceStatus); this.onChangeSubject.next(this.userPreferenceStatus);
} }
/**
* Check if an item is present in the storage
* @param property Name of the property
*/
hasItem(property: string) {
if (!property) {
return;
}
return this.storage.hasItem(
this.getPropertyKey(property)
);
}
/** /**
* Gets the active storage prefix for preferences. * Gets the active storage prefix for preferences.
* @returns Storage prefix * @returns Storage prefix
@@ -152,21 +153,6 @@ export class UserPreferencesService {
return this.defaults.supportedPageSizes; return this.defaults.supportedPageSizes;
} }
/** Prevents the CSRF Token from being submitted if true. Only valid for Process Services. */
set disableCSRF(csrf: boolean) {
let storedCSRF = this.storage.getItem('DISABLE_CSRF');
if (csrf !== null && csrf !== undefined) {
if (csrf.toString() === storedCSRF) {
this.set('DISABLE_CSRF', csrf);
}
}
}
get disableCSRF(): boolean {
return this.get('DISABLE_CSRF') === 'true';
}
/** Pagination size. */ /** Pagination size. */
set paginationSize(value: number) { set paginationSize(value: number) {
this.set('PAGINATION_SIZE', value); this.set('PAGINATION_SIZE', value);
@@ -195,74 +181,4 @@ export class UserPreferencesService {
return this.appConfig.get<string>('locale') || this.translate.getBrowserLang() || 'en'; return this.appConfig.get<string>('locale') || this.translate.getBrowserLang() || 'en';
} }
get providers(): string {
if (this.storage.hasItem('providers')) {
return this.storage.getItem('providers');
} else {
return this.appConfig.get('providers', 'ECM');
}
}
set providers(providers: string) {
if (providers !== this.providers) {
this.storage.setItem('providers', providers);
}
}
get bpmHost(): string {
if (this.storage.hasItem('bpmHost')) {
return this.storage.getItem('bpmHost');
} else {
return this.appConfig.get('bpmHost');
}
}
set bpmHost(bpmHost: string) {
if (bpmHost !== this.bpmHost) {
this.storage.setItem('bpmHost', bpmHost);
}
}
get ecmHost(): string {
if (this.storage.hasItem('ecmHost')) {
return this.storage.getItem('ecmHost');
} else {
return this.appConfig.get('ecmHost');
}
}
set ecmHost(ecmHost: string) {
if (ecmHost !== this.ecmHost) {
this.storage.setItem('ecmHost', ecmHost);
}
}
get oauthConfig(): OauthConfigModel {
if (this.storage.hasItem('oauthConfig')) {
return JSON.parse(this.storage.getItem('oauthConfig'));
} else {
return this.appConfig.get<OauthConfigModel>('oauth2');
}
}
set oauthConfig(oauthConfig: OauthConfigModel) {
if (JSON.stringify(oauthConfig) !== JSON.stringify(this.oauthConfig)) {
this.storage.setItem('oauthConfig', JSON.stringify(oauthConfig));
}
}
get authType(): string {
if (this.storage.hasItem('authType')) {
return this.storage.getItem('authType');
} else {
return this.appConfig.get<string>('authType', 'BASIC');
}
}
set authType(authType: string) {
if (authType !== this.authType) {
this.storage.setItem('authType', authType);
}
}
} }

View File

@@ -19,13 +19,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HostSettingsComponent } from './host-settings.component'; import { HostSettingsComponent } from './host-settings.component';
import { setupTestBed } from '../testing/setupTestBed'; import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
import { UserPreferencesService } from '../services/user-preferences.service'; import { AppConfigService } from '../app-config/app-config.service';
describe('HostSettingsComponent', () => { describe('HostSettingsComponent', () => {
let fixture: ComponentFixture<HostSettingsComponent>; let fixture: ComponentFixture<HostSettingsComponent>;
let component: HostSettingsComponent; let component: HostSettingsComponent;
let userPreferences: UserPreferencesService; let appConfigService: AppConfigService;
let element: any; let element: any;
setupTestBed({ setupTestBed({
@@ -35,7 +35,7 @@ describe('HostSettingsComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(HostSettingsComponent); fixture = TestBed.createComponent(HostSettingsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
userPreferences = TestBed.get(UserPreferencesService); appConfigService = TestBed.get(AppConfigService);
element = fixture.nativeElement; element = fixture.nativeElement;
}); });
@@ -46,9 +46,9 @@ describe('HostSettingsComponent', () => {
describe('Providers', () => { describe('Providers', () => {
beforeEach(() => { beforeEach(() => {
userPreferences.providers = 'ECM'; appConfigService.config.providers = 'ECM';
userPreferences.authType = 'OAUTH'; appConfigService.config.authType = 'OAUTH';
userPreferences.oauthConfig = { appConfigService.config.oauth2 = {
host: 'http://localhost:6543', host: 'http://localhost:6543',
redirectUri: '/', redirectUri: '/',
silentLogin: false, silentLogin: false,
@@ -57,6 +57,8 @@ describe('HostSettingsComponent', () => {
scope: 'openid', scope: 'openid',
secret: '' secret: ''
}; };
appConfigService.load();
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -64,7 +66,7 @@ describe('HostSettingsComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should not show the providers select box if you hav eine porovider', (done) => { it('should not show the providers select box if you have any provider', (done) => {
component.providers = ['BPM']; component.providers = ['BPM'];
component.ngOnInit(); component.ngOnInit();
@@ -76,7 +78,7 @@ describe('HostSettingsComponent', () => {
}); });
}); });
it('should show the providers select box if you hav eine porovider', (done) => { it('should show the providers select box if you have any provider', (done) => {
component.providers = ['BPM', 'ECM']; component.providers = ['BPM', 'ECM'];
component.ngOnInit(); component.ngOnInit();
@@ -96,7 +98,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput; let bpmUrlInput;
beforeEach(() => { beforeEach(() => {
userPreferences.providers = 'BPM'; appConfigService.config.providers = 'BPM';
appConfigService.load();
fixture.detectChanges(); fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost'); bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost'); ecmUrlInput = element.querySelector('#ecmHost');
@@ -148,7 +151,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput; let bpmUrlInput;
beforeEach(() => { beforeEach(() => {
userPreferences.providers = 'ECM'; appConfigService.config.providers = 'ECM';
appConfigService.load();
fixture.detectChanges(); fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost'); bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost'); ecmUrlInput = element.querySelector('#ecmHost');
@@ -195,7 +199,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput; let bpmUrlInput;
beforeEach(() => { beforeEach(() => {
userPreferences.providers = 'ALL'; appConfigService.config.providers = 'ALL';
appConfigService.load();
fixture.detectChanges(); fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost'); bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost'); ecmUrlInput = element.querySelector('#ecmHost');
@@ -269,9 +274,9 @@ describe('HostSettingsComponent', () => {
let clientIdInput; let clientIdInput;
beforeEach(() => { beforeEach(() => {
userPreferences.providers = 'ALL'; appConfigService.config.providers = 'ALL';
userPreferences.authType = 'OAUTH'; appConfigService.config.authType = 'OAUTH';
userPreferences.oauthConfig = { appConfigService.config.oauth2 = {
host: 'http://localhost:6543', host: 'http://localhost:6543',
redirectUri: '/', redirectUri: '/',
silentLogin: false, silentLogin: false,
@@ -280,6 +285,7 @@ describe('HostSettingsComponent', () => {
scope: 'openid', scope: 'openid',
secret: '' secret: ''
}; };
appConfigService.load();
fixture.detectChanges(); fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost'); bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost'); ecmUrlInput = element.querySelector('#ecmHost');

View File

@@ -17,7 +17,10 @@
import { Component, EventEmitter, Output, ViewEncapsulation, OnInit, Input } from '@angular/core'; import { Component, EventEmitter, Output, ViewEncapsulation, OnInit, Input } from '@angular/core';
import { Validators, FormGroup, FormBuilder, AbstractControl, FormControl } from '@angular/forms'; import { Validators, FormGroup, FormBuilder, AbstractControl, FormControl } from '@angular/forms';
import { UserPreferencesService } from '../services/user-preferences.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { StorageService } from '../services/storage.service';
import { AlfrescoApiService } from '../services/alfresco-api.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Component({ @Component({
selector: 'adf-host-settings', selector: 'adf-host-settings',
@@ -62,7 +65,9 @@ export class HostSettingsComponent implements OnInit {
bpmHostChange = new EventEmitter<string>(); bpmHostChange = new EventEmitter<string>();
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private userPreferencesService: UserPreferencesService) { private storageService: StorageService,
private alfrescoApiService: AlfrescoApiService,
private appConfig: AppConfigService) {
} }
ngOnInit() { ngOnInit() {
@@ -70,16 +75,16 @@ export class HostSettingsComponent implements OnInit {
this.showSelectProviders = false; this.showSelectProviders = false;
} }
let providerSelected = this.userPreferencesService.providers; let providerSelected = this.appConfig.get<string>(AppConfigValues.PROVIDERS);
this.form = this.formBuilder.group({ this.form = this.formBuilder.group({
providersControl: [providerSelected, Validators.required], providersControl: [providerSelected, Validators.required],
authType: this.userPreferencesService.authType authType: this.appConfig.get<string>(AppConfigValues.AUTHTYPE)
}); });
this.addFormGroups(); this.addFormGroups();
if (this.userPreferencesService.authType === 'OAUTH') { if (this.appConfig.get<string>(AppConfigValues.AUTHTYPE) === 'OAUTH') {
this.addOAuthFormGroup(); this.addOAuthFormGroup();
} }
@@ -127,24 +132,25 @@ export class HostSettingsComponent implements OnInit {
} }
private createOAuthFormGroup(): AbstractControl { private createOAuthFormGroup(): AbstractControl {
const oAuthConfig: any = this.userPreferencesService.oauthConfig ? this.userPreferencesService.oauthConfig : {}; let oauth = <OauthConfigModel> this.appConfig.get(AppConfigValues.OAUTHCONFIG, {});
return this.formBuilder.group({ return this.formBuilder.group({
host: [oAuthConfig.host, [Validators.required, Validators.pattern(this.HOST_REGEX)]], host: [oauth.host, [Validators.required, Validators.pattern(this.HOST_REGEX)]],
clientId: [oAuthConfig.clientId, Validators.required], clientId: [oauth.clientId, Validators.required],
redirectUri: [oAuthConfig.redirectUri, Validators.required], redirectUri: [oauth.redirectUri, Validators.required],
scope: [oAuthConfig.scope, Validators.required], scope: [oauth.scope, Validators.required],
secret: oAuthConfig.secret, secret: oauth.secret,
silentLogin: oAuthConfig.silentLogin, silentLogin: oauth.silentLogin,
implicitFlow: oAuthConfig.implicitFlow implicitFlow: oauth.implicitFlow
}); });
} }
private createBPMFormControl(): AbstractControl { private createBPMFormControl(): AbstractControl {
return new FormControl(this.userPreferencesService.bpmHost, [Validators.required, Validators.pattern(this.HOST_REGEX)]); return new FormControl(this.appConfig.get<string>(AppConfigValues.BPMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
} }
private createECMFormControl(): AbstractControl { private createECMFormControl(): AbstractControl {
return new FormControl(this.userPreferencesService.ecmHost, [Validators.required, Validators.pattern(this.HOST_REGEX)]); return new FormControl(this.appConfig.get<string>(AppConfigValues.ECMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
} }
onCancel() { onCancel() {
@@ -152,7 +158,7 @@ export class HostSettingsComponent implements OnInit {
} }
onSubmit(values: any) { onSubmit(values: any) {
this.userPreferencesService.providers = values.providersControl; this.storageService.setItem(AppConfigValues.PROVIDERS, values.providersControl);
if (this.isBPM()) { if (this.isBPM()) {
this.saveBPMValues(values); this.saveBPMValues(values);
@@ -167,21 +173,22 @@ export class HostSettingsComponent implements OnInit {
this.saveOAuthValues(values); this.saveOAuthValues(values);
} }
this.userPreferencesService.authType = values.authType; this.storageService.setItem(AppConfigValues.AUTHTYPE, values.authType);
this.alfrescoApiService.reset();
this.success.emit(true); this.success.emit(true);
} }
private saveOAuthValues(values: any) { private saveOAuthValues(values: any) {
this.userPreferencesService.oauthConfig = values.oauthConfig; this.storageService.setItem(AppConfigValues.OAUTHCONFIG, JSON.stringify(values.oauthConfig));
} }
private saveBPMValues(values: any) { private saveBPMValues(values: any) {
this.userPreferencesService.bpmHost = values.bpmHost; this.storageService.setItem(AppConfigValues.BPMHOST, values.bpmHost);
} }
private saveECMValues(values: any) { private saveECMValues(values: any) {
this.userPreferencesService.ecmHost = values.ecmHost; this.storageService.setItem(AppConfigValues.ECMHOST, values.ecmHost);
} }
isBPM(): boolean { isBPM(): boolean {

View File

@@ -15,22 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { Component, EventEmitter, Input, OnChanges,
Component, Output, SimpleChanges, ViewChild, ViewEncapsulation
EventEmitter,
Input,
OnChanges,
Output,
SimpleChanges,
ViewChild,
ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { import { ActivitiContentService, AppConfigService, AppConfigValues,
ActivitiContentService, StartFormComponent, FormRenderingService, FormValues
AppConfigService,
StartFormComponent,
FormRenderingService,
FormValues
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model'; import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessDefinitionRepresentation } from './../models/process-definition.model'; import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
@@ -138,7 +127,7 @@ export class StartProcessInstanceComponent implements OnChanges {
} }
getAlfrescoRepositoryName(): string { getAlfrescoRepositoryName(): string {
let alfrescoRepositoryName = this.appConfig.get<string>('alfrescoRepositoryName'); let alfrescoRepositoryName = this.appConfig.get<string>(AppConfigValues.ALFRESCO_REPOSITORY_NAME);
if (!alfrescoRepositoryName) { if (!alfrescoRepositoryName) {
alfrescoRepositoryName = 'alfresco-1'; alfrescoRepositoryName = 'alfresco-1';
} }

View File

@@ -15,11 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { async } from '@angular/core/testing';
import { mockError, fakeProcessFilters } from '../../mock'; import { mockError, fakeProcessFilters } from '../../mock';
import { FilterProcessRepresentationModel } from '../models/filter-process.model'; import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessFilterService } from './process-filter.service'; import { ProcessFilterService } from './process-filter.service';
import { AlfrescoApiServiceMock, AlfrescoApiService, AppConfigService, StorageService, UserPreferencesService, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { AlfrescoApiServiceMock, AlfrescoApiService, AppConfigService, StorageService, setupTestBed, CoreModule } from '@alfresco/adf-core';
declare let jasmine: any; declare let jasmine: any;
@@ -28,7 +28,6 @@ describe('Process filter', () => {
let service: ProcessFilterService; let service: ProcessFilterService;
let apiService: AlfrescoApiService; let apiService: AlfrescoApiService;
let alfrescoApi: any; let alfrescoApi: any;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -37,8 +36,7 @@ describe('Process filter', () => {
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService); apiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService() );
apiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService() );
service = new ProcessFilterService(apiService); service = new ProcessFilterService(apiService);
alfrescoApi = apiService.getInstance(); alfrescoApi = apiService.getInstance();
}); });

View File

@@ -15,13 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { async } from '@angular/core/testing';
import { exampleProcess, fakeProcessInstances } from '../../mock'; import { exampleProcess, fakeProcessInstances } from '../../mock';
import { mockError, fakeProcessDef, fakeTasksList } from '../../mock'; import { mockError, fakeProcessDef, fakeTasksList } from '../../mock';
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model'; import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model'; import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessService } from './process.service'; import { ProcessService } from './process.service';
import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigService, StorageService, UserPreferencesService, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigService, StorageService, setupTestBed, CoreModule } from '@alfresco/adf-core';
declare let moment: any; declare let moment: any;
@@ -30,7 +30,6 @@ describe('ProcessService', () => {
let service: ProcessService; let service: ProcessService;
let apiService: AlfrescoApiService; let apiService: AlfrescoApiService;
let alfrescoApi: any; let alfrescoApi: any;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -39,8 +38,7 @@ describe('ProcessService', () => {
}); });
beforeEach(() => { beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService); apiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService() );
apiService = new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService() );
service = new ProcessService(apiService); service = new ProcessService(apiService);
alfrescoApi = apiService.getInstance(); alfrescoApi = apiService.getInstance();
}); });

View File

@@ -15,22 +15,17 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { async } from '@angular/core/testing';
import { import { fakeAppFilter, fakeAppPromise, fakeFilters } from '../../mock';
fakeAppFilter,
fakeAppPromise,
fakeFilters
} from '../../mock';
import { FilterRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel } from '../models/filter.model';
import { TaskFilterService } from './task-filter.service'; import { TaskFilterService } from './task-filter.service';
import { AlfrescoApiServiceMock, LogService, AppConfigService, StorageService, setupTestBed, CoreModule, UserPreferencesService } from '@alfresco/adf-core'; import { AlfrescoApiServiceMock, LogService, AppConfigService, StorageService, setupTestBed, CoreModule } from '@alfresco/adf-core';
declare let jasmine: any; declare let jasmine: any;
describe('Activiti Task filter Service', () => { describe('Activiti Task filter Service', () => {
let service: TaskFilterService; let service: TaskFilterService;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -39,8 +34,7 @@ describe('Activiti Task filter Service', () => {
}); });
beforeEach(async(() => { beforeEach(async(() => {
userPreferences = TestBed.get(UserPreferencesService); service = new TaskFilterService(new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService()), new LogService(new AppConfigService(null)));
service = new TaskFilterService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()), new LogService(new AppConfigService(null)));
jasmine.Ajax.install(); jasmine.Ajax.install();
})); }));

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { async } from '@angular/core/testing';
import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { import {
@@ -35,14 +35,13 @@ import {
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './tasklist.service'; import { TaskListService } from './tasklist.service';
import { AlfrescoApiServiceMock, LogService, AppConfigService, StorageService, UserPreferencesService } from '@alfresco/adf-core'; import { AlfrescoApiServiceMock, LogService, AppConfigService, StorageService } from '@alfresco/adf-core';
declare let jasmine: any; declare let jasmine: any;
describe('Activiti TaskList Service', () => { describe('Activiti TaskList Service', () => {
let service: TaskListService; let service: TaskListService;
let userPreferences: UserPreferencesService;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -51,8 +50,7 @@ describe('Activiti TaskList Service', () => {
}); });
beforeEach(async(() => { beforeEach(async(() => {
userPreferences = TestBed.get(UserPreferencesService); service = new TaskListService(new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService() ), new LogService(new AppConfigService(null)));
service = new TaskListService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService() ), new LogService(new AppConfigService(null)));
jasmine.Ajax.install(); jasmine.Ajax.install();
})); }));