Skip to content

Commit 7cef006

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/poc/prime-angular-poc/angular/common-20.3.25
2 parents 6a32901 + c8ab0ca commit 7cef006

25 files changed

Lines changed: 247 additions & 129 deletions

File tree

.github/workflows/build-pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: "Get current pull request"
4646
id: PR
47-
uses: 8BitJonny/gh-get-current-pr@2.2.0
47+
uses: 8BitJonny/gh-get-current-pr@4.0.0
4848
with:
4949
github-token: ${{secrets.GITHUB_TOKEN}}
5050
filterOutClosed: true
@@ -91,7 +91,7 @@ jobs:
9191
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}}
9292

9393
- name: "Get current pull request"
94-
uses: 8BitJonny/gh-get-current-pr@2.2.0
94+
uses: 8BitJonny/gh-get-current-pr@4.0.0
9595
id: PR
9696
with:
9797
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -157,7 +157,7 @@ jobs:
157157
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}}
158158

159159
- name: "Get current pull request"
160-
uses: 8BitJonny/gh-get-current-pr@2.2.0
160+
uses: 8BitJonny/gh-get-current-pr@4.0.0
161161
id: PR
162162
with:
163163
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -215,7 +215,7 @@ jobs:
215215
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}}
216216

217217
- name: "Get current pull request"
218-
uses: 8BitJonny/gh-get-current-pr@2.2.0
218+
uses: 8BitJonny/gh-get-current-pr@4.0.0
219219
id: PR
220220
with:
221221
github-token: ${{secrets.GITHUB_TOKEN}}

prime-angular-frontend/src/app/app-routing.module.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { AccessDeniedComponent } from '@lib/modules/root-routes/components/acces
66
import { MaintenanceComponent } from '@lib/modules/root-routes/components/maintenance/maintenance.component';
77
import { PageNotFoundComponent } from '@lib/modules/root-routes/components/page-not-found/page-not-found.component';
88
import { HelpComponent } from '@lib/modules/root-routes/components/help/help.component';
9-
import { UnderagedComponent } from '@lib/modules/root-routes/components/underaged/underaged.component';
109

1110
import { AuthRoutes } from '@auth/auth.routes';
1211
import { EnrolmentRoutes } from '@enrolment/enrolment.routes';
@@ -19,6 +18,7 @@ import { SatEformsRoutes } from '@sat/sat-eforms.routes';
1918
import { GisEnrolmentRoutes } from '@gis/gis-enrolment.routes';
2019
import { HealthAuthSiteRegRoutes } from '@health-auth/health-auth-site-reg.routes';
2120
import { PaperEnrolmentRoutes } from '@paper-enrolment/paper-enrolment.routes';
21+
import { NotEligibleComponent } from '@lib/modules/root-routes/components/not-eligible/not-eligible.component';
2222

2323
const routes: Routes = [
2424
{
@@ -70,11 +70,18 @@ const routes: Routes = [
7070
},
7171
{
7272
path: AppRoutes.UNDERAGED,
73-
component: UnderagedComponent,
73+
component: NotEligibleComponent,
7474
data: {
7575
title: 'Underaged'
7676
}
7777
},
78+
{
79+
path: AppRoutes.IDENTITY_INSURANCE_LEVEL,
80+
component: NotEligibleComponent,
81+
data: {
82+
title: 'Identity Insurance Level Not Met'
83+
}
84+
},
7885
{
7986
path: AppRoutes.MAINTENANCE,
8087
component: MaintenanceComponent,
@@ -110,4 +117,4 @@ const routes: Routes = [
110117
imports: [RouterModule.forRoot(routes, { enableTracing: false })],
111118
exports: [RouterModule]
112119
})
113-
export class AppRoutingModule {}
120+
export class AppRoutingModule { }

prime-angular-frontend/src/app/app.routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export class AppRoutes {
22
public static DENIED = 'denied';
33
public static UNDERAGED = 'underaged';
4+
public static IDENTITY_INSURANCE_LEVEL = 'identity-insurance-level';
45
public static MAINTENANCE = 'maintenance';
56
public static PAGE_NOT_FOUND = 'page-not-found';
67
public static HELP = 'help';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { provideHttpClientTesting } from '@angular/common/http/testing';
2+
import { TestBed } from '@angular/core/testing';
3+
import { RouterTestingModule } from '@angular/router/testing';
4+
import { AuthService } from '@auth/shared/services/auth.service';
5+
import { AppRoutes } from 'app/app.routes';
6+
import { KeycloakService } from 'keycloak-angular';
7+
import { MockAuthService } from 'test/mocks/mock-auth.service';
8+
9+
import { IdentityInsuranceLevelGuard } from './identity-insurance-level.guard';
10+
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11+
import { NotEligibleComponent } from '@lib/modules/root-routes/components/not-eligible/not-eligible.component';
12+
13+
describe('IdentityInsuranceLevelGuard', () => {
14+
let guard: IdentityInsuranceLevelGuard;
15+
16+
beforeEach(() => {
17+
TestBed.configureTestingModule({
18+
imports: [RouterTestingModule.withRoutes([
19+
{
20+
path: AppRoutes.IDENTITY_INSURANCE_LEVEL,
21+
component: NotEligibleComponent
22+
}
23+
])],
24+
providers: [
25+
{
26+
provide: AuthService,
27+
useClass: MockAuthService
28+
},
29+
KeycloakService,
30+
provideHttpClient(withInterceptorsFromDi()),
31+
provideHttpClientTesting()
32+
]
33+
});
34+
guard = TestBed.inject(IdentityInsuranceLevelGuard);
35+
});
36+
37+
it('should be created', () => {
38+
expect(guard).toBeTruthy();
39+
});
40+
});
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Injectable } from '@angular/core';
2+
import { Route, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
3+
4+
import { Observable } from 'rxjs';
5+
import { map } from 'rxjs/operators';
6+
import { AppRoutes } from 'app/app.routes';
7+
import { AuthService } from '@auth/shared/services/auth.service';
8+
import { BcscUser } from '@auth/shared/models/bcsc-user.model';
9+
10+
@Injectable({
11+
providedIn: 'root'
12+
})
13+
export class IdentityInsuranceLevelGuard {
14+
constructor(
15+
private router: Router,
16+
private authService: AuthService
17+
) { }
18+
19+
public canActivate(
20+
next: ActivatedRouteSnapshot,
21+
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
22+
return this.checkIdentityInsuranceLevel();
23+
}
24+
25+
public canActivateChild(
26+
next: ActivatedRouteSnapshot,
27+
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
28+
return this.canActivate(next, state);
29+
}
30+
31+
public canLoad(
32+
route: Route,
33+
segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
34+
return this.checkIdentityInsuranceLevel();
35+
}
36+
37+
private checkIdentityInsuranceLevel(): Observable<boolean> | Promise<boolean> | boolean {
38+
return this.authService.getUser$()
39+
.pipe(
40+
map((user: BcscUser) => user.identityInsuranceLevel),
41+
map((identityInsuranceLevel: number) => identityInsuranceLevel < 3),
42+
map((unauthorized: boolean) => {
43+
if (unauthorized) {
44+
this.router.navigate([AppRoutes.IDENTITY_INSURANCE_LEVEL]);
45+
return false;
46+
}
47+
48+
return true;
49+
})
50+
);
51+
}
52+
}

prime-angular-frontend/src/app/core/guards/underaged.guard.spec.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@ import { TestBed } from '@angular/core/testing';
33
import { RouterTestingModule } from '@angular/router/testing';
44
import { AuthService } from '@auth/shared/services/auth.service';
55
import { AppRoutes } from 'app/app.routes';
6-
import { UnderagedComponent } from '@lib/modules/root-routes/components/underaged/underaged.component';
76
import { KeycloakService } from 'keycloak-angular';
87
import { MockAuthService } from 'test/mocks/mock-auth.service';
98

109

1110
import { UnderagedGuard } from './underaged.guard';
1211
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
12+
import { NotEligibleComponent } from '@lib/modules/root-routes/components/not-eligible/not-eligible.component';
1313

1414

1515
describe('UnderagedGuard', () => {
16-
let guard: UnderagedGuard;
16+
let guard: UnderagedGuard;
1717

18-
beforeEach(() => {
19-
TestBed.configureTestingModule({
20-
imports: [RouterTestingModule.withRoutes([
21-
{
22-
path: AppRoutes.UNDERAGED,
23-
component: UnderagedComponent
24-
}
25-
])],
26-
providers: [
27-
{
28-
provide: AuthService,
29-
useClass: MockAuthService
30-
},
31-
KeycloakService,
32-
provideHttpClient(withInterceptorsFromDi()),
33-
provideHttpClientTesting()
34-
]
35-
});
36-
guard = TestBed.inject(UnderagedGuard);
37-
});
18+
beforeEach(() => {
19+
TestBed.configureTestingModule({
20+
imports: [RouterTestingModule.withRoutes([
21+
{
22+
path: AppRoutes.UNDERAGED,
23+
component: NotEligibleComponent
24+
}
25+
])],
26+
providers: [
27+
{
28+
provide: AuthService,
29+
useClass: MockAuthService
30+
},
31+
KeycloakService,
32+
provideHttpClient(withInterceptorsFromDi()),
33+
provideHttpClientTesting()
34+
]
35+
});
36+
guard = TestBed.inject(UnderagedGuard);
37+
});
3838

39-
it('should be created', () => {
40-
expect(guard).toBeTruthy();
41-
});
39+
it('should be created', () => {
40+
expect(guard).toBeTruthy();
41+
});
4242
});

prime-angular-frontend/src/app/lib/modules/root-routes/components/underaged/underaged.component.html renamed to prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<div class="row justify-content-center">
33
<div class="col-sm-12 col-md-8 col-lg-6 text-center">
44
<p class="mb-5">
5-
You are not eligible to enrol in PRIME. If you believe you have received this page in error, please call
6-
<app-prime-phone></app-prime-phone> or email <app-prime-email></app-prime-email>
5+
You are not eligible to enrol in PRIME. If you believe you have received this page in error, please
6+
email <app-prime-email></app-prime-email>
77
</p>
88
</div>
99
</div>

prime-angular-frontend/src/app/lib/modules/root-routes/components/underaged/underaged.component.scss renamed to prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.scss

File renamed without changes.

prime-angular-frontend/src/app/lib/modules/root-routes/components/underaged/underaged.component.spec.ts renamed to prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
22
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
33

4-
import { UnderagedComponent } from './underaged.component';
4+
import { NotEligibleComponent } from './not-eligible.component';
55

6-
describe('UnderagedComponent', () => {
7-
let component: UnderagedComponent;
8-
let fixture: ComponentFixture<UnderagedComponent>;
6+
describe('NotEligibleComponent', () => {
7+
let component: NotEligibleComponent;
8+
let fixture: ComponentFixture<NotEligibleComponent>;
99

1010
beforeEach(waitForAsync(() => {
1111
TestBed.configureTestingModule({
12-
declarations: [UnderagedComponent],
12+
declarations: [NotEligibleComponent],
1313
schemas: [CUSTOM_ELEMENTS_SCHEMA]
1414
})
1515
.compileComponents();
1616
}));
1717

1818
beforeEach(() => {
19-
fixture = TestBed.createComponent(UnderagedComponent);
19+
fixture = TestBed.createComponent(NotEligibleComponent);
2020
component = fixture.componentInstance;
2121
fixture.detectChanges();
2222
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-not-eligible',
5+
templateUrl: './not-eligible.component.html',
6+
styleUrls: ['./not-eligible.component.scss'],
7+
standalone: false
8+
})
9+
export class NotEligibleComponent implements OnInit {
10+
constructor() { }
11+
12+
public ngOnInit(): void { }
13+
}

0 commit comments

Comments
 (0)