Removed fallback and starting using simple token

This commit is contained in:
VitoAlbano
2024-10-14 12:53:01 +01:00
parent 892c1a9b88
commit 1869b78e0e
4 changed files with 10 additions and 8 deletions

View File

@@ -18,7 +18,7 @@
import { TestBed } from '@angular/core/testing';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
import { JwtHelperService } from '../services/jwt-helper.service';
import { JwtHelperService, JWT_STORAGE_SERVICE } from '../services/jwt-helper.service';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { NoopTranslateModule } from '../../testing/noop-translate.module';
@@ -29,7 +29,8 @@ describe('Auth Guard SSO role service', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, MatDialogModule]
imports: [NoopTranslateModule, MatDialogModule],
providers: [{ provide: JWT_STORAGE_SERVICE, useValue: { getItem: () => {}, setItem: () => {}, removeItem: () => {} } }]
});
localStorage.clear();
jwtHelperService = TestBed.inject(JwtHelperService);

View File

@@ -29,7 +29,7 @@ import {
} from '../mock/identity-user.mock';
import { mockGroups, mockJoinGroupRequest } from '../mock/identity-group.mock';
import { IdentityUserService } from './identity-user.service';
import { JwtHelperService } from './jwt-helper.service';
import { JwtHelperService, JWT_STORAGE_SERVICE } from './jwt-helper.service';
import { mockToken } from '../mock/jwt-helper.service.spec';
import { IdentityRoleModel } from '../models/identity-role.model';
import { AdfHttpClient } from '../../../../api/src';
@@ -53,7 +53,7 @@ describe('IdentityUserService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule],
providers: [StorageService, AdfHttpClient]
providers: [{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }, AdfHttpClient]
});
storageService = TestBed.inject(StorageService);
service = TestBed.inject(IdentityUserService);

View File

@@ -17,7 +17,7 @@
import { TestBed } from '@angular/core/testing';
import { UserAccessService } from './user-access.service';
import { JwtHelperService } from './jwt-helper.service';
import { JwtHelperService, JWT_STORAGE_SERVICE } from './jwt-helper.service';
import { AppConfigService } from '../../app-config';
import { HttpClientTestingModule } from '@angular/common/http/testing';
@@ -29,7 +29,7 @@ describe('UserAccessService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [UserAccessService]
providers: [UserAccessService, { provide: JWT_STORAGE_SERVICE, useValue: {} }]
});
userAccessService = TestBed.inject(UserAccessService);
jwtHelperService = TestBed.inject(JwtHelperService);

View File

@@ -16,7 +16,7 @@
*/
import { APP_INITIALIZER, Injectable, NgModule } from '@angular/core';
import { AuthModule, RedirectAuthService } from '../auth';
import { AuthModule, JWT_STORAGE_SERVICE, RedirectAuthService } from '../auth';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppConfigService, StoragePrefixFactory } from '../app-config';
@@ -47,7 +47,8 @@ export class NoopRedirectAuthService extends RedirectAuthService {
useFactory: loadAppConfig,
deps: [AppConfigService, StorageService, AdfHttpClient, StoragePrefixFactory],
multi: true
}
},
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }
]
})
export class NoopAuthModule {}