mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Modified redirectToPreviousUrl to use the standalone page parameter if no redirect url is found in the store.
Removed unused import that was causing merge conflict. Once again try to fix merge conflict. Added routeService to server module providers. Changed order of providers. Minor change to ServerAuthService to make method signature consistent with AuthService. Try adding RouteService to browser-app module to see if that fixes travis build. One more try at getting the CI build to work. Removed change to browser module.
This commit is contained in:
@@ -86,8 +86,6 @@ describe('AuthService test', () => {
|
||||
],
|
||||
});
|
||||
authService = TestBed.get(AuthService);
|
||||
routeServiceMock = TestBed.get(RouteService);
|
||||
spyOn(authService, 'setRedirectUrl');
|
||||
});
|
||||
|
||||
it('should return the authentication status object when user credentials are correct', () => {
|
||||
@@ -130,31 +128,6 @@ describe('AuthService test', () => {
|
||||
expect(authService.logout.bind(null)).toThrow();
|
||||
});
|
||||
|
||||
it ('should dispatch authentication', () => {
|
||||
authService.doAuthentication(true, '', '');
|
||||
expect(mockStore.dispatch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it ('should set redirect url to previous page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
authService.doAuthentication(true, '', '');
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(authService.setRedirectUrl).toHaveBeenCalledWith('/collection/123');
|
||||
});
|
||||
|
||||
it ('should set redirect url to current page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
authService.doAuthentication(false, '', '');
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(authService.setRedirectUrl).toHaveBeenCalledWith('/home');
|
||||
});
|
||||
|
||||
it ('should not set redirect url to /login', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['/login', '/login']));
|
||||
authService.doAuthentication(true, '', '');
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(authService.setRedirectUrl).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('', () => {
|
||||
@@ -247,9 +220,12 @@ describe('AuthService test', () => {
|
||||
});
|
||||
authService = new AuthService({}, window, undefined, authReqService, router, routeService, cookieService, store, rdbService);
|
||||
storage = (authService as any).storage;
|
||||
routeServiceMock = TestBed.get(RouteService);
|
||||
routerStub = TestBed.get(Router);
|
||||
spyOn(storage, 'get');
|
||||
spyOn(storage, 'remove');
|
||||
spyOn(storage, 'set');
|
||||
|
||||
}));
|
||||
|
||||
it('should throw false when token is not valid', () => {
|
||||
@@ -271,5 +247,32 @@ describe('AuthService test', () => {
|
||||
expect(storage.remove).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it ('should set redirect url to previous page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
authService.redirectToPreviousUrl(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/collection/123']);
|
||||
});
|
||||
|
||||
it ('should set redirect url to current page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
authService.redirectToPreviousUrl(false);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/home']);
|
||||
});
|
||||
|
||||
it ('should redirect to / and not to /login', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['/login', '/login']));
|
||||
authService.redirectToPreviousUrl(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||
});
|
||||
|
||||
it ('should redirect to / when no redirect url is found', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['']));
|
||||
authService.redirectToPreviousUrl(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -54,7 +54,7 @@ export class ServerAuthService extends AuthService {
|
||||
/**
|
||||
* Redirect to the route navigated before the login
|
||||
*/
|
||||
public redirectToPreviousUrl() {
|
||||
public redirectToPreviousUrl(isStandalonePage: boolean) {
|
||||
this.getRedirectUrl().pipe(
|
||||
take(1))
|
||||
.subscribe((redirectUrl) => {
|
||||
|
@@ -13,13 +13,6 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AuthService } from '../../core/auth/auth.service';
|
||||
import { AuthServiceStub } from '../testing/auth-service-stub';
|
||||
import { AppState } from '../../app.reducer';
|
||||
import {AppRoutingModule} from '../../app-routing.module';
|
||||
import {PageNotFoundComponent} from '../../pagenotfound/pagenotfound.component';
|
||||
import {APP_BASE_HREF} from '@angular/common';
|
||||
import {RouterStub} from '../testing/router-stub';
|
||||
import {Router} from '@angular/router';
|
||||
import {RouteService} from '../services/route.service';
|
||||
import {routeServiceStub} from '../testing/route-service-stub';
|
||||
|
||||
describe('LogInComponent', () => {
|
||||
|
||||
@@ -45,18 +38,13 @@ describe('LogInComponent', () => {
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
StoreModule.forRoot(authReducer),
|
||||
AppRoutingModule,
|
||||
TranslateModule.forRoot()
|
||||
],
|
||||
declarations: [
|
||||
LogInComponent,
|
||||
PageNotFoundComponent
|
||||
LogInComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: AuthService, useClass: AuthServiceStub},
|
||||
{provide: APP_BASE_HREF, useValue: '/'},
|
||||
{provide: Router, useClass: RouterStub},
|
||||
{provide: RouteService, useValue: routeServiceStub }
|
||||
{provide: AuthService, useClass: AuthServiceStub}
|
||||
],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
|
@@ -88,7 +88,6 @@ export class LogInComponent implements OnDestroy, OnInit {
|
||||
* @constructor
|
||||
* @param {AuthService} authService
|
||||
* @param {FormBuilder} formBuilder
|
||||
* @param {RouteService} routeService
|
||||
* @param {Router} router
|
||||
* @param {Store<State>} store
|
||||
*/
|
||||
|
@@ -64,7 +64,7 @@ export function createTranslateLoader() {
|
||||
{
|
||||
provide: SubmissionService,
|
||||
useClass: ServerSubmissionService
|
||||
},
|
||||
}
|
||||
]
|
||||
})
|
||||
export class ServerAppModule {
|
||||
|
Reference in New Issue
Block a user