[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

47
.vscode/settings.json vendored
View File

@@ -1,26 +1,27 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/coverage": true,
"**/.happypack": true
},
"editor.renderIndentGuides": true,
"markdownlint.config": {
"MD032": false,
"MD004": false,
"MD024": false,
"MD009": false,
"MD013": false,
"MD036": false,
"MD033" : false,
"MD031" : false
},
"cSpell.words": [
"mincount",
"webscript"
]
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/coverage": true,
"**/.happypack": true
},
"editor.renderIndentGuides": true,
"window.zoomLevel": 8,
"html.format.wrapAttributes": "force",
"markdownlint.config": {
"MD032": false,
"MD004": false,
"MD024": false,
"MD009": false,
"MD013": false,
"MD036": false,
"MD033": false,
"MD031": false
},
"cSpell.words": ["mincount", "webscript"]
}

View File

@@ -6,7 +6,7 @@ import { ChartsModule } from 'ng2-charts';
import { HttpClientModule } from '@angular/common/http';
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 { AdfModule } from './adf.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 { ThemePickerModule } from './components/theme-picker/theme-picker';
import { DebugAppConfigService } from './services/debug-app-config.service';
import { routing } from './app.routes';
import { ReactiveFormsModule } from '@angular/forms';
@@ -110,7 +109,7 @@ import { NotificationsComponent } from './components/notifications/notifications
NotificationsComponent
],
providers: [
{ provide: AppConfigService, useClass: DebugAppConfigService },
{ provide: AppConfigService, useClass: DebugAppConfigService }, // not use this service in production
{
provide: TRANSLATION_PROVIDER,
multi: true,
@@ -129,11 +128,7 @@ import { NotificationsComponent } from './components/notifications/notifications
},
PreviewService
],
entryComponents: [
VersionManagerDialogAdapterComponent,
MetadataDialogAdapterComponent
],
entryComponents: [VersionManagerDialogAdapterComponent, MetadataDialogAdapterComponent],
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 { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry } from 'alfresco-js-api';
import {
AuthenticationService, ContentService, TranslationService,
AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService,
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
UploadService, DataColumn, DataRow, UserPreferencesService,
PaginationComponent, FormValues, DisplayMode, UserPreferenceValues, InfinitePaginationComponent
@@ -56,7 +56,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
displayMode = DisplayMode.List;
includeFields = ['isFavorite', 'isLocked', 'aspectNames'];
baseShareUrl = this.preference.ecmHost + '/preview/s/';
baseShareUrl = this.appConfig.get<string>(AppConfigValues.ECMHOST) + '/preview/s/';
toolbarColor = 'default';
@@ -188,6 +188,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
private translateService: TranslationService,
private router: Router,
private logService: LogService,
private appConfig: AppConfigService,
private preference: UserPreferencesService,
private preview: PreviewService,
@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.
- **Experimental** ![](docassets/images/ExperimentalIcon.png) - The component is available for
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.
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)
![\#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

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) |
| [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) |
| [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) |
| [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) |

View File

@@ -1,11 +1,12 @@
---
Added: v2.0.0
Status: Active
Status: Internal
Last reviewed: 2018-06-13
---
# 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
![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>
```
```ts
@NgModule({
providers: [
{ provide: AppConfigService, useClass: DebugAppConfigService },
]
)]
```
## Class members
### Properties

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

View File

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

View File

@@ -16,9 +16,8 @@
*/
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 { TestBed } from '@angular/core/testing';
declare let jasmine: any;
@@ -26,7 +25,6 @@ describe('DocumentListService', () => {
let service: DocumentListService;
let alfrescoApiService: AlfrescoApiService;
let userPreferences: UserPreferencesService;
let fakeEntryNode = {
'entry': {
@@ -96,10 +94,8 @@ describe('DocumentListService', () => {
});
beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService);
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);
jasmine.Ajax.install();
});

View File

@@ -16,7 +16,7 @@
*/
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 { FileNode, FolderNode } from '../../mock';
import { ContentActionHandler } from '../models/content-action.model';
@@ -27,7 +27,6 @@ describe('FolderActionsService', () => {
let service: FolderActionsService;
let documentListService: DocumentListService;
let userPreferences: UserPreferencesService;
setupTestBed({
imports: [
@@ -39,10 +38,8 @@ describe('FolderActionsService', () => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
userPreferences = TestBed.get(UserPreferencesService);
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);
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
});

View File

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

View File

@@ -15,26 +15,23 @@
* 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 { TestBed } from '@angular/core/testing';
import { ContentTestingModule } from '../../testing/content.testing.module';
declare let jasmine: any;
describe('TagService', () => {
let service: TagService;
let userPreferences: UserPreferencesService;
setupTestBed({
imports: [
CoreModule.forRoot()
]
imports: [ContentTestingModule]
});
beforeEach(() => {
userPreferences = TestBed.get(UserPreferencesService);
service = new TagService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()), new LogService(new AppConfigService(null)));
service = TestBed.get(TagService);
});
beforeEach(() => {

View File

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

View File

@@ -21,11 +21,24 @@ import { ObjectUtils } from '../utils/object-utils';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
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()
export class AppConfigService {
static APP_CONFIG_LANGUAGES_KEY = 'languages';
config: any = {
application: {
name: 'Alfresco ADF Application'

View File

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

View File

@@ -273,10 +273,19 @@
"description": "BPM host",
"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": {
"description": "The context root of the BPM host",
"type": "string"
},
"disableCSRF": {
"description": "The context root of the BPM host",
"type": "boolean"
},
"application": {
"description": "Application's global configuration",
"type": "object",
@@ -460,7 +469,8 @@
},
"authType": {
"description": "Kind of authentication BASIC or OAUTH, default value BASIC",
"type": "string"
"type": "string",
"enum": [ "BASIC", "OAUTH" ]
},
"oauth2": {
"description": "AUTH configuration parameters",

View File

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

View File

@@ -122,7 +122,6 @@
"BASIC": "Basic Auth",
"SSO": "SSO",
"IMPLICIT-FLOW": "implicitFlow",
"TYPE-AUTH": "Authentication type",
"PROVIDER": "Provider",
"REQUIRED": "The field is required",
"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 { AppConfigService } from '../app-config/app-config.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service';
@Component({
@@ -35,7 +35,7 @@ export class LanguageMenuComponent implements OnInit {
}
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) {
this.languages = languagesCongifApp;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,20 +16,14 @@
*/
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot,
Router
} from '@angular/router';
import { AppConfigService } from '../app-config/app-config.service';
import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot, Router } from '@angular/router';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { AuthenticationService } from './authentication.service';
import { UserPreferencesService } from './user-preferences.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable()
export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService,
private router: Router,
private userPreference: UserPreferencesService,
private appConfig: AppConfigService) {}
constructor(private authService: AuthenticationService, private router: Router, private appConfig: AppConfigService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkLogin(state.url);
@@ -44,7 +38,7 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
return true;
}
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin() ) {
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin()) {
this.authService.setRedirect({ provider: 'BPM', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
@@ -54,12 +48,11 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
}
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 {
return this.appConfig &&
this.appConfig.get<string>('loginRoute') ?
this.appConfig.get<string>('loginRoute') : 'login';
return this.appConfig && this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
}
}

View File

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

View File

@@ -17,20 +17,20 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, CanActivate,
CanActivateChild, RouterStateSnapshot, Router
ActivatedRouteSnapshot, CanActivate,
CanActivateChild, RouterStateSnapshot, Router
} from '@angular/router';
import { AuthenticationService } from './authentication.service';
import { Observable } from 'rxjs/Observable';
import { AppConfigService } from '../app-config/app-config.service';
import { UserPreferencesService } from './user-preferences.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable()
export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService,
private router: Router,
private userPreference: UserPreferencesService,
private appConfig: AppConfigService) {}
private appConfig: AppConfigService) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> {
const redirectUrl = state.url;
@@ -45,8 +45,8 @@ export class AuthGuard implements CanActivate, CanActivateChild {
if (this.authService.isLoggedIn()) {
return true;
}
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin() ) {
this.authService.setRedirect({ provider: 'ALL', url: redirectUrl } );
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin()) {
this.authService.setRedirect({ provider: 'ALL', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
@@ -56,12 +56,13 @@ export class AuthGuard implements CanActivate, CanActivateChild {
}
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 {
return this.appConfig &&
this.appConfig.get<string>('loginRoute') ?
this.appConfig.get<string>('loginRoute') : 'login';
this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ?
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 { CookieService } from './cookie.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 { CoreTestingModule } from '../testing/core.testing.module';
@@ -29,7 +29,7 @@ declare let jasmine: any;
describe('AuthenticationService', () => {
let apiService: AlfrescoApiService;
let authService: AuthenticationService;
let preferences: UserPreferencesService;
let appConfigService: AppConfigService;
let storage: StorageService;
let cookie: CookieService;
@@ -40,7 +40,6 @@ describe('AuthenticationService', () => {
beforeEach(() => {
apiService = TestBed.get(AlfrescoApiService);
authService = TestBed.get(AuthenticationService);
preferences = TestBed.get(UserPreferencesService);
cookie = TestBed.get(CookieService);
cookie.clear();
@@ -60,7 +59,9 @@ describe('AuthenticationService', () => {
describe('remember me', () => {
beforeEach(() => {
preferences.providers = 'ECM';
appConfigService = TestBed.get(AppConfigService);
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset();
});
@@ -124,7 +125,8 @@ describe('AuthenticationService', () => {
describe('when the setting is ECM', () => {
beforeEach(() => {
preferences.providers = 'ECM';
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset();
});
@@ -276,26 +278,27 @@ describe('AuthenticationService', () => {
it('[ECM] should set/get redirectUrl when provider is ECM', () => {
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', () => {
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', () => {
authService.setRedirect(null);
expect(authService.getRedirect(preferences.providers)).toBeNull();
expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
});
});
describe('when the setting is BPM', () => {
beforeEach(() => {
preferences.providers = 'BPM';
appConfigService.config.providers = 'BPM';
appConfigService.load();
apiService.reset();
});
@@ -429,26 +432,27 @@ describe('AuthenticationService', () => {
it('[BPM] should set/get redirectUrl when provider is BPM', () => {
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', () => {
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', () => {
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 ', () => {
beforeEach(() => {
preferences.providers = 'ALL';
appConfigService.config.providers = 'ALL';
appConfigService.load();
apiService.reset();
});
@@ -546,25 +550,25 @@ describe('AuthenticationService', () => {
it('[ALL] should set/get redirectUrl when provider is ALL', () => {
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', () => {
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', () => {
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', () => {
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 { LogService } from './log.service';
import { StorageService } from './storage.service';
import { UserPreferencesService } from './user-preferences.service';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
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_UNTIL = 1000 * 60 * 60 * 24 * 30 ;
@@ -39,7 +39,7 @@ export class AuthenticationService {
onLogout: Subject<any> = new Subject<any>();
constructor(
private preferences: UserPreferencesService,
private appConfig: AppConfigService,
private alfrescoApi: AlfrescoApiService,
private storage: StorageService,
private cookie: CookieService,
@@ -73,7 +73,7 @@ export class AuthenticationService {
this.saveTickets();
this.onLogin.next(response);
return {
type: this.preferences.providers,
type: this.appConfig.get(AppConfigValues.PROVIDERS),
ticket: response
};
})
@@ -83,7 +83,7 @@ export class AuthenticationService {
/**
* Logs the user in with SSO
*/
ssoImplictiLogin() {
ssoImplicitLogin() {
this.alfrescoApi.getInstance().implicitLogin();
}

View File

@@ -18,7 +18,7 @@
/* tslint:disable:no-console */
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 { Subject } from 'rxjs/Subject';
@@ -26,7 +26,7 @@ import { Subject } from 'rxjs/Subject';
export class LogService {
get currentLogLevel() {
let configLevel: string = this.appConfig.get<string>('logLevel');
let configLevel: string = this.appConfig.get<string>(AppConfigValues.LOG_LEVEL);
if (configLevel) {
return this.getLogLevel(configLevel);

View File

@@ -15,115 +15,64 @@
* limitations under the License.
*/
import { inject, TestBed } from '@angular/core/testing';
import { Title } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
import { TestBed } from '@angular/core/testing';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreModule } from '../core.module';
import { AppConfigService } from '../app-config/app-config.service';
import { PageTitleService } from './page-title.service';
import { CoreTestingModule } from '../testing/core.testing.module';
import { TranslationService } from './translation.service';
import { TranslationMock } from '../mock/translation.service.mock';
class TestConfig {
private setup: any = {
applicationName: undefined
};
titleService: Title = null;
appTitleService: PageTitleService = null;
translationService: TranslationService;
constructor(setup: any = {}) {
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: [
CoreTestingModule
],
providers: [
titleServiceProvider,
appConfigProvider,
PageTitleService,
{
provide: TranslationService,
useClass: TranslationMock
}
]
});
inject([Title, PageTitleService, TranslationService], (titleService, appTitleService, translationService) => {
this.titleService = titleService;
this.appTitleService = appTitleService;
this.translationService = translationService;
})();
}
}
import { Title } from '@angular/platform-browser';
describe('AppTitle service', () => {
it('should set default application name', () => {
const { appTitleService, titleService } = new TestConfig({
applicationName: undefined
});
appTitleService.setTitle();
expect(titleService.setTitle).toHaveBeenCalledWith('Alfresco ADF Application');
let titleService: any;
let translationService: any;
let pageTitleService: any;
let appConfigService: any;
let titleServiceSpy: any;
setupTestBed({
imports: [
CoreModule.forRoot()
]
});
beforeEach(() => {
titleService = TestBed.get(Title);
pageTitleService = TestBed.get(PageTitleService);
translationService = TestBed.get(TranslationService);
appConfigService = TestBed.get(AppConfigService);
titleServiceSpy = spyOn(titleService, 'setTitle').and.callThrough();
appConfigService.config.application.name = 'My application';
});
it('should set default application name', () => {
appConfigService.config.application = {};
pageTitleService.setTitle();
expect(titleServiceSpy).toHaveBeenCalledWith('Alfresco ADF Application');
});
it('should set only the application name', () => {
const { appTitleService, titleService } = new TestConfig({
applicationName: 'My application'
});
appTitleService.setTitle();
expect(titleService.setTitle).toHaveBeenCalledWith('My application');
pageTitleService.setTitle();
expect(titleServiceSpy).toHaveBeenCalledWith('My application');
});
it('should append application name to the title', () => {
const { appTitleService, titleService } = new TestConfig({
applicationName: 'My application'
});
appTitleService.setTitle('My page');
expect(titleService.setTitle).toHaveBeenCalledWith('My page - My application');
pageTitleService.setTitle('My page');
expect(titleServiceSpy).toHaveBeenCalledWith('My page - My application');
});
it('should update title on language change', () => {
const { appTitleService, titleService, translationService } = new TestConfig({
applicationName: 'My application'
});
spyOn(translationService, 'instant').and.returnValues('hello', 'привет');
appTitleService.setTitle('key');
expect(titleService.setTitle).toHaveBeenCalledWith('hello - My application');
pageTitleService.setTitle('key');
expect(titleServiceSpy).toHaveBeenCalledWith('hello - My application');
(<any> titleService).setTitle.calls.reset();
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 { AppConfigService } from '../app-config/app-config.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { LogService } from './log.service';
import { UserPreferencesService } from './user-preferences.service';
@Injectable()
export class SettingsService {
constructor(
private appConfig: AppConfigService,
private logService: LogService,
private preferences: UserPreferencesService) {
constructor(private appConfig: AppConfigService,
private logService: LogService) {
}
/** @deprecated in 1.6.0 */
public get ecmHost(): string {
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 */
public set csrfDisabled(csrfDisabled: boolean) {
this.logService.log(`SettingsService.csrfDisabled is deprecated. Use UserPreferencesService.disableCSRF instead.`);
this.preferences.disableCSRF = csrfDisabled;
}
/** @deprecated in 1.6.0 */
@@ -49,7 +45,7 @@ export class SettingsService {
/** @deprecated in 1.6.0 */
public get bpmHost(): string {
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 */
@@ -66,12 +62,11 @@ export class SettingsService {
/** @deprecated in 1.7.0 */
public getProviders(): string {
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 */
public setProviders(providers: string) {
this.logService.log(`SettingsService.getProviders is deprecated. Use UserPreferencesService.authType instead.`);
this.preferences.providers = providers;
this.logService.log(`SettingsService.aetProviders is deprecated. Use the app-config.json`);
}
}

View File

@@ -20,7 +20,6 @@ import { TranslateService } from '@ngx-translate/core';
import { AppConfigService } from '../app-config/app-config.service';
import { StorageService } from './storage.service';
import { UserPreferencesService } from './user-preferences.service';
import { UserPreferenceValues } from './user-preferences.service';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
@@ -154,13 +153,4 @@ describe('UserPreferencesService', () => {
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 { StorageService } from './storage.service';
import 'rxjs/add/operator/distinctUntilChanged';
import { OauthConfigModel } from '../models/oauth-config.model';
export enum UserPreferenceValues {
PaginationSize = 'PAGINATION_SIZE',
DisableCSRF = 'DISABLE_CSRF',
Locale = 'LOCALE',
SupportedPageSizes = 'supportedPageSizes',
oauthConfig = 'oauthConfig',
ecmHost = 'ecmHost',
bpmHost = 'bpmHost',
providers = 'providers',
authType = 'authType'
SupportedPageSizes = 'supportedPageSizes'
}
@Injectable()
@@ -45,11 +38,7 @@ export class UserPreferencesService {
locale: 'en'
};
private userPreferenceStatus: any = {
paginationSize: 25,
supportedPageSizes: [5, 10, 15, 20],
LOCALE: 'en'
};
private userPreferenceStatus: any = this.defaults;
/**
* @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.paginationSize : this.appConfig.get('pagination.size', this.defaults.paginationSize);
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);
}
/**
* 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.
* @returns Storage prefix
@@ -152,21 +153,6 @@ export class UserPreferencesService {
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. */
set paginationSize(value: number) {
this.set('PAGINATION_SIZE', value);
@@ -195,74 +181,4 @@ export class UserPreferencesService {
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 { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { UserPreferencesService } from '../services/user-preferences.service';
import { AppConfigService } from '../app-config/app-config.service';
describe('HostSettingsComponent', () => {
let fixture: ComponentFixture<HostSettingsComponent>;
let component: HostSettingsComponent;
let userPreferences: UserPreferencesService;
let appConfigService: AppConfigService;
let element: any;
setupTestBed({
@@ -35,7 +35,7 @@ describe('HostSettingsComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(HostSettingsComponent);
component = fixture.componentInstance;
userPreferences = TestBed.get(UserPreferencesService);
appConfigService = TestBed.get(AppConfigService);
element = fixture.nativeElement;
});
@@ -46,9 +46,9 @@ describe('HostSettingsComponent', () => {
describe('Providers', () => {
beforeEach(() => {
userPreferences.providers = 'ECM';
userPreferences.authType = 'OAUTH';
userPreferences.oauthConfig = {
appConfigService.config.providers = 'ECM';
appConfigService.config.authType = 'OAUTH';
appConfigService.config.oauth2 = {
host: 'http://localhost:6543',
redirectUri: '/',
silentLogin: false,
@@ -57,6 +57,8 @@ describe('HostSettingsComponent', () => {
scope: 'openid',
secret: ''
};
appConfigService.load();
fixture.detectChanges();
});
@@ -64,7 +66,7 @@ describe('HostSettingsComponent', () => {
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.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.ngOnInit();
@@ -96,7 +98,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput;
beforeEach(() => {
userPreferences.providers = 'BPM';
appConfigService.config.providers = 'BPM';
appConfigService.load();
fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost');
@@ -148,7 +151,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput;
beforeEach(() => {
userPreferences.providers = 'ECM';
appConfigService.config.providers = 'ECM';
appConfigService.load();
fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost');
@@ -195,7 +199,8 @@ describe('HostSettingsComponent', () => {
let bpmUrlInput;
beforeEach(() => {
userPreferences.providers = 'ALL';
appConfigService.config.providers = 'ALL';
appConfigService.load();
fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost');
@@ -269,9 +274,9 @@ describe('HostSettingsComponent', () => {
let clientIdInput;
beforeEach(() => {
userPreferences.providers = 'ALL';
userPreferences.authType = 'OAUTH';
userPreferences.oauthConfig = {
appConfigService.config.providers = 'ALL';
appConfigService.config.authType = 'OAUTH';
appConfigService.config.oauth2 = {
host: 'http://localhost:6543',
redirectUri: '/',
silentLogin: false,
@@ -280,6 +285,7 @@ describe('HostSettingsComponent', () => {
scope: 'openid',
secret: ''
};
appConfigService.load();
fixture.detectChanges();
bpmUrlInput = element.querySelector('#bpmHost');
ecmUrlInput = element.querySelector('#ecmHost');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,7 @@
* 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 { Observable } from 'rxjs/Observable';
import {
@@ -35,14 +35,13 @@ import {
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model';
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;
describe('Activiti TaskList Service', () => {
let service: TaskListService;
let userPreferences: UserPreferencesService;
setupTestBed({
imports: [
@@ -51,8 +50,7 @@ describe('Activiti TaskList Service', () => {
});
beforeEach(async(() => {
userPreferences = TestBed.get(UserPreferencesService);
service = new TaskListService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService() ), new LogService(new AppConfigService(null)));
service = new TaskListService(new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService() ), new LogService(new AppConfigService(null)));
jasmine.Ajax.install();
}));