Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: "Get current pull request"
id: PR
uses: 8BitJonny/gh-get-current-pr@2.2.0
uses: 8BitJonny/gh-get-current-pr@4.0.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
filterOutClosed: true
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}}

- name: "Get current pull request"
uses: 8BitJonny/gh-get-current-pr@2.2.0
uses: 8BitJonny/gh-get-current-pr@4.0.0
id: PR
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}}

- name: "Get current pull request"
uses: 8BitJonny/gh-get-current-pr@2.2.0
uses: 8BitJonny/gh-get-current-pr@4.0.0
id: PR
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}}

- name: "Get current pull request"
uses: 8BitJonny/gh-get-current-pr@2.2.0
uses: 8BitJonny/gh-get-current-pr@4.0.0
id: PR
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down
13 changes: 10 additions & 3 deletions prime-angular-frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AccessDeniedComponent } from '@lib/modules/root-routes/components/acces
import { MaintenanceComponent } from '@lib/modules/root-routes/components/maintenance/maintenance.component';
import { PageNotFoundComponent } from '@lib/modules/root-routes/components/page-not-found/page-not-found.component';
import { HelpComponent } from '@lib/modules/root-routes/components/help/help.component';
import { UnderagedComponent } from '@lib/modules/root-routes/components/underaged/underaged.component';

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

const routes: Routes = [
{
Expand Down Expand Up @@ -70,11 +70,18 @@ const routes: Routes = [
},
{
path: AppRoutes.UNDERAGED,
component: UnderagedComponent,
component: NotEligibleComponent,
data: {
title: 'Underaged'
}
},
{
path: AppRoutes.IDENTITY_INSURANCE_LEVEL,
component: NotEligibleComponent,
data: {
title: 'Identity Insurance Level Not Met'
}
},
{
path: AppRoutes.MAINTENANCE,
component: MaintenanceComponent,
Expand Down Expand Up @@ -110,4 +117,4 @@ const routes: Routes = [
imports: [RouterModule.forRoot(routes, { enableTracing: false })],
exports: [RouterModule]
})
export class AppRoutingModule {}
export class AppRoutingModule { }
1 change: 1 addition & 0 deletions prime-angular-frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export class AppRoutes {
public static DENIED = 'denied';
public static UNDERAGED = 'underaged';
public static IDENTITY_INSURANCE_LEVEL = 'identity-insurance-level';

Check warning on line 4 in prime-angular-frontend/src/app/app.routes.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this public static property readonly.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx94UQCvAIt9uRjy&open=AZ7xGx94UQCvAIt9uRjy&pullRequest=2875
public static MAINTENANCE = 'maintenance';
public static PAGE_NOT_FOUND = 'page-not-found';
public static HELP = 'help';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AuthService } from '@auth/shared/services/auth.service';
import { AppRoutes } from 'app/app.routes';
import { KeycloakService } from 'keycloak-angular';
import { MockAuthService } from 'test/mocks/mock-auth.service';

import { IdentityInsuranceLevelGuard } from './identity-insurance-level.guard';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { NotEligibleComponent } from '@lib/modules/root-routes/components/not-eligible/not-eligible.component';

describe('IdentityInsuranceLevelGuard', () => {
let guard: IdentityInsuranceLevelGuard;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([
{
path: AppRoutes.IDENTITY_INSURANCE_LEVEL,
component: NotEligibleComponent
}
])],
providers: [
{
provide: AuthService,
useClass: MockAuthService
},
KeycloakService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
});
guard = TestBed.inject(IdentityInsuranceLevelGuard);
});

it('should be created', () => {
expect(guard).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Injectable } from '@angular/core';
import { Route, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';

import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { AppRoutes } from 'app/app.routes';
import { AuthService } from '@auth/shared/services/auth.service';
import { BcscUser } from '@auth/shared/models/bcsc-user.model';

@Injectable({
providedIn: 'root'
})
export class IdentityInsuranceLevelGuard {
constructor(
private router: Router,

Check warning on line 15 in prime-angular-frontend/src/app/core/guards/identity-insurance-level.guard.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'router: Router' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx9aUQCvAIt9uRjw&open=AZ7xGx9aUQCvAIt9uRjw&pullRequest=2875
private authService: AuthService

Check warning on line 16 in prime-angular-frontend/src/app/core/guards/identity-insurance-level.guard.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'authService: AuthService' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx9aUQCvAIt9uRjx&open=AZ7xGx9aUQCvAIt9uRjx&pullRequest=2875
) { }

public canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.checkIdentityInsuranceLevel();
}

public canActivateChild(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.canActivate(next, state);
}

public canLoad(
route: Route,
segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
return this.checkIdentityInsuranceLevel();
}

private checkIdentityInsuranceLevel(): Observable<boolean> | Promise<boolean> | boolean {
return this.authService.getUser$()
.pipe(
map((user: BcscUser) => user.identityInsuranceLevel),
map((identityInsuranceLevel: number) => identityInsuranceLevel < 3),
map((unauthorized: boolean) => {
if (unauthorized) {
this.router.navigate([AppRoutes.IDENTITY_INSURANCE_LEVEL]);
return false;
}

return true;
})
);
}
}
50 changes: 25 additions & 25 deletions prime-angular-frontend/src/app/core/guards/underaged.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AuthService } from '@auth/shared/services/auth.service';
import { AppRoutes } from 'app/app.routes';
import { UnderagedComponent } from '@lib/modules/root-routes/components/underaged/underaged.component';
import { KeycloakService } from 'keycloak-angular';
import { MockAuthService } from 'test/mocks/mock-auth.service';


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


describe('UnderagedGuard', () => {
let guard: UnderagedGuard;
let guard: UnderagedGuard;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([
{
path: AppRoutes.UNDERAGED,
component: UnderagedComponent
}
])],
providers: [
{
provide: AuthService,
useClass: MockAuthService
},
KeycloakService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
});
guard = TestBed.inject(UnderagedGuard);
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([
{
path: AppRoutes.UNDERAGED,
component: NotEligibleComponent
}
])],
providers: [
{
provide: AuthService,
useClass: MockAuthService
},
KeycloakService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
});
guard = TestBed.inject(UnderagedGuard);
});

it('should be created', () => {
expect(guard).toBeTruthy();
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="row justify-content-center">
<div class="col-sm-12 col-md-8 col-lg-6 text-center">
<p class="mb-5">
You are not eligible to enrol in PRIME. If you believe you have received this page in error, please call
<app-prime-phone></app-prime-phone> or email <app-prime-email></app-prime-email>
You are not eligible to enrol in PRIME. If you believe you have received this page in error, please
email <app-prime-email></app-prime-email>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';

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

describe('UnderagedComponent', () => {
let component: UnderagedComponent;
let fixture: ComponentFixture<UnderagedComponent>;
describe('NotEligibleComponent', () => {
let component: NotEligibleComponent;
let fixture: ComponentFixture<NotEligibleComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [UnderagedComponent],
declarations: [NotEligibleComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(UnderagedComponent);
fixture = TestBed.createComponent(NotEligibleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-not-eligible',
templateUrl: './not-eligible.component.html',
styleUrls: ['./not-eligible.component.scss'],
standalone: false

Check failure on line 7 in prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Components, Directives and Pipes should not opt out of standalone. Following this guide is highly recommended: https://angular.dev/reference/migrations/standalone

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx4yUQCvAIt9uRjt&open=AZ7xGx4yUQCvAIt9uRjt&pullRequest=2875
})
export class NotEligibleComponent implements OnInit {
constructor() { }

public ngOnInit(): void { }

Check failure on line 12 in prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Lifecycle methods should not be empty

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx4yUQCvAIt9uRju&open=AZ7xGx4yUQCvAIt9uRju&pullRequest=2875

Check failure on line 12 in prime-angular-frontend/src/app/lib/modules/root-routes/components/not-eligible/not-eligible.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unexpected empty method 'ngOnInit'.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7xGx4yUQCvAIt9uRjv&open=AZ7xGx4yUQCvAIt9uRjv&pullRequest=2875
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PageNotFoundComponent } from './components/page-not-found/page-not-foun
import { MaintenanceComponent } from './components/maintenance/maintenance.component';
import { PageSimpleComponent } from './components/page-simple/page-simple.component';
import { HelpComponent } from './components/help/help.component';
import { UnderagedComponent } from './components/underaged/underaged.component';
import { NotEligibleComponent } from './components/not-eligible/not-eligible.component';

@NgModule({
imports: [
Expand All @@ -19,15 +19,15 @@ import { UnderagedComponent } from './components/underaged/underaged.component';
PageNotFoundComponent,
MaintenanceComponent,
HelpComponent,
UnderagedComponent
NotEligibleComponent,
],
exports: [
PageSimpleComponent,
AccessDeniedComponent,
PageNotFoundComponent,
MaintenanceComponent,
HelpComponent,
UnderagedComponent
NotEligibleComponent,
]
})
export class RootRoutesModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class EnrolleeAccessTermEnrolmentComponent extends AbstractComponent impl
phone,
phoneExtension,
enrolleeCareSettings,
identityInsuranceLevel,
...remainder
} = enrollee;

Expand All @@ -119,7 +120,8 @@ export class EnrolleeAccessTermEnrolmentComponent extends AbstractComponent impl
email,
smsPhone,
phone,
phoneExtension
phoneExtension,
identityInsuranceLevel
},
// Provide the default and allow it to be overridden
collectionNoticeAccepted: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import { EnrolleeAbsence } from '@shared/models/enrollee-absence.model';
import { AdjudicationRoutes } from '@adjudication/adjudication.routes';

@Component({
selector: 'app-enrollee-overview',
templateUrl: './enrollee-overview.component.html',
styleUrls: ['./enrollee-overview.component.scss'],
standalone: false
selector: 'app-enrollee-overview',
templateUrl: './enrollee-overview.component.html',
styleUrls: ['./enrollee-overview.component.scss'],
standalone: false
})
export class EnrolleeOverviewComponent extends AdjudicationContainerComponent implements OnInit {
public enrollee: HttpEnrollee;
Expand Down Expand Up @@ -144,6 +144,7 @@ export class EnrolleeOverviewComponent extends AdjudicationContainerComponent im
phone,
phoneExtension,
userProvidedGpid,
identityInsuranceLevel,
...remainder
} = enrollee;

Expand All @@ -168,7 +169,8 @@ export class EnrolleeOverviewComponent extends AdjudicationContainerComponent im
smsPhone,
phone,
phoneExtension,
userProvidedGpid
userProvidedGpid,
identityInsuranceLevel
},
// Provide the default and allow it to be overridden
collectionNoticeAccepted: false,
Expand Down
Loading
Loading