Skip to content

Commit f75b562

Browse files
Merge pull request #310 from bcgov/fix/pen-2107
Fix/pen 2107
2 parents 62a63f5 + fd1266f commit f75b562

File tree

9 files changed

+46
-29
lines changed

9 files changed

+46
-29
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci-api-build.and.test.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
working-directory: api
2626

2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929
with:
3030
fetch-depth: 0
31-
- uses: actions/setup-java@v3
31+
- uses: actions/setup-java@v4
3232
with:
3333
java-version: 17
3434
distribution: oracle
35-
- uses: actions/cache@v3
35+
- uses: actions/cache@v4
3636
with:
3737
path: ~/.m2/repository
3838
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -41,7 +41,7 @@ jobs:
4141
- name: Run unit tests
4242
run: mvn -f pom.xml clean package
4343
- name: Cache SonarCloud packages
44-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4545
with:
4646
path: ~/.sonar/cache
4747
key: ${{ runner.os }}-sonar
@@ -54,7 +54,7 @@ jobs:
5454
env:
5555
GITHUB_TOKEN: ${{ github.token }}
5656
- name: Run Trivy vulnerability scanner in repo mode
57-
uses: aquasecurity/trivy-action@0.10.0
57+
uses: aquasecurity/trivy-action@0.24.0
5858
with:
5959
scan-type: 'fs'
6060
ignore-unfixed: true
@@ -63,6 +63,6 @@ jobs:
6363
severity: 'CRITICAL'
6464

6565
- name: Upload Trivy scan results to GitHub Security tab
66-
uses: github/codeql-action/upload-sarif@v2
66+
uses: github/codeql-action/upload-sarif@v3
6767
with:
6868
sarif_file: 'trivy-results.sarif'

.github/workflows/deploy-to.openshift-dev.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ on:
4949
jobs:
5050
build-and-deploy-dev:
5151
name: Build and deploy to OpenShift DEV
52-
# ubuntu-20.04 can also be used.
5352
runs-on: ubuntu-22.04
5453
environment: dev
5554

@@ -59,7 +58,7 @@ jobs:
5958

6059
steps:
6160
- name: Check for required secrets
62-
uses: actions/github-script@v6
61+
uses: actions/github-script@v7
6362
with:
6463
script: |
6564
const secrets = {
@@ -93,14 +92,14 @@ jobs:
9392
core.info(`✅ All the required secrets are set`);
9493
}
9594
- name: Check out repository
96-
uses: actions/checkout@v3
95+
uses: actions/checkout@v4
9796

9897
- name: Determine image tags
9998
if: env.IMAGE_TAGS == ''
10099
run: |
101100
echo "IMAGE_TAGS=latest ${GITHUB_SHA::12}" | tee -a $GITHUB_ENV
102101
- name: Login to Docker Hub
103-
uses: docker/login-action@v2
102+
uses: docker/login-action@v3
104103
with:
105104
registry: ${{ env.DOCKER_ARTIFACTORY_REPO }}
106105
username: ${{ secrets.DOCKER_HUB_USERNAME }}
@@ -138,7 +137,7 @@ jobs:
138137
oc: 4
139138

140139
# https://github.com/redhat-actions/oc-login#readme
141-
- uses: actions/checkout@v3
140+
- uses: actions/checkout@v4
142141

143142
- name: Deploy API
144143
run: |

.github/workflows/deploy-to.openshift-prod.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ on:
4343
jobs:
4444
openshift-ci-cd:
4545
name: Deploy to OpenShift PROD
46-
# ubuntu-20.04 can also be used.
4746
runs-on: ubuntu-22.04
4847
environment: production
4948

@@ -53,7 +52,7 @@ jobs:
5352

5453
steps:
5554
- name: Check for required secrets
56-
uses: actions/github-script@v6
55+
uses: actions/github-script@v7
5756
with:
5857
script: |
5958
const secrets = {
@@ -91,7 +90,7 @@ jobs:
9190
}
9291

9392
- name: Check out repository
94-
uses: actions/checkout@v3
93+
uses: actions/checkout@v4
9594

9695
- name: Get latest tag
9796
uses: actions-ecosystem/action-get-latest-tag@v1
@@ -103,7 +102,7 @@ jobs:
103102
oc: 4
104103

105104
# https://github.com/redhat-actions/oc-login#readme
106-
- uses: actions/checkout@v3
105+
- uses: actions/checkout@v4
107106

108107
- name: Deploy API
109108
run: |

.github/workflows/deploy-to.openshift-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
steps:
6262
- name: Check for required secrets
63-
uses: actions/github-script@v6
63+
uses: actions/github-script@v7
6464
with:
6565
script: |
6666
const secrets = {
@@ -98,7 +98,7 @@ jobs:
9898
}
9999
100100
- name: Check out repository
101-
uses: actions/checkout@v3
101+
uses: actions/checkout@v4
102102

103103
- name: Install oc
104104
uses: redhat-actions/openshift-tools-installer@v1

.github/workflows/tag-create.git.and.imagestream.tag.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333

3434
steps:
3535
- name: Check out repository
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737

3838
- name: Create tag
39-
uses: actions/github-script@v6
39+
uses: actions/github-script@v7
4040
with:
4141
script: |
4242
github.rest.git.createRef({
@@ -52,7 +52,7 @@ jobs:
5252
oc: 4
5353

5454
# https://github.com/redhat-actions/oc-login#readme
55-
- uses: actions/checkout@v3
55+
- uses: actions/checkout@v4
5656
- name: Tag in OpenShift
5757
run: |
5858
set -eux

api/src/main/java/ca/bc/gov/educ/penreg/api/rest/RestUtils.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.fasterxml.jackson.core.type.TypeReference;
1515
import com.fasterxml.jackson.databind.ObjectMapper;
1616
import com.google.common.collect.Sets;
17+
import java.time.*;
18+
import java.time.format.*;
1719
import lombok.Getter;
1820
import lombok.extern.slf4j.Slf4j;
1921
import lombok.val;
@@ -399,7 +401,10 @@ public List<SchoolContact> getStudentRegistrationContactList(final String mincod
399401
throw new PenRegAPIRuntimeException("API call to Institute API received null response when getting student registration contacts, contact the Ministry for more info.");
400402
}
401403

402-
return schoolContactSearchWrapper.getContent();
404+
return schoolContactSearchWrapper.getContent().stream().filter(contact -> {
405+
final String expiryDate = contact.getExpiryDate();
406+
return contact.getExpiryDate() == null || (expiryDate != null && LocalDate.parse(expiryDate, DateTimeFormatter.ISO_DATE_TIME).isAfter(LocalDate.now()));
407+
}).toList();
403408
}catch(Exception e){
404409
log.error("API call to Institute API failure getting student registration contacts :: {}", e.getMessage());
405410
throw new PenRegAPIRuntimeException("API call to Institute API failure getting student registration contacts, contact the Ministry for more info.");

api/src/test/java/ca/bc/gov/educ/penreg/api/batch/processor/PenRegBatchProcessorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public void testProcessPenRegBatchFileFromTSW_GivenmincodeInvalidSchoolCloseDate
713713
@Transactional
714714
public void testProcessPenRegBatchFileFromTSW_GivenmincodeInvalidSchoolOpenDate_ShouldCreateRecordLOADFAILInDB() throws IOException {
715715
final School school = this.createMockSchool();
716-
school.setOpenedDate("2024-09-01T00:00:00");
716+
school.setOpenedDate(LocalDateTime.now().plusYears(1).toString());
717717
when(this.restUtils.getSchoolByMincode(anyString())).thenReturn(Optional.of(school));
718718
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("sample_5_K12_OK.txt")).getFile());
719719
final byte[] bFile = Files.readAllBytes(file.toPath());

api/src/test/java/ca/bc/gov/educ/penreg/api/rest/RestUtilsTest.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.databind.ObjectMapper;
1111
import io.nats.client.Message;
1212
import java.net.*;
13+
import java.time.*;
1314
import java.util.*;
1415
import lombok.val;
1516
import org.junit.Before;
@@ -108,8 +109,10 @@ private GradeCode[] createGradeCodeArray() {
108109

109110
private SchoolContactSearchWrapper createSchoolContactSearchWrapper() {
110111
SchoolContactSearchWrapper schoolSearchWrapper = new SchoolContactSearchWrapper();
111-
schoolSearchWrapper.setContent(Arrays.asList(SchoolContact.builder().email("[email protected]").firstName("Joe").lastName("Blow").build(),
112-
SchoolContact.builder().email("[email protected]").firstName("2").lastName("2").build()));
112+
schoolSearchWrapper.setContent(Arrays.asList(
113+
SchoolContact.builder().email("[email protected]").firstName("Joe").lastName("Blow").expiryDate(LocalDateTime.now().minusDays(1).toString()).build(),
114+
SchoolContact.builder().email("[email protected]").firstName("2").lastName("2").expiryDate(null).build(),
115+
SchoolContact.builder().email("[email protected]").firstName("Joe").lastName("Blow").expiryDate(LocalDateTime.now().plusDays(1).toString()).build()));
113116

114117
return schoolSearchWrapper;
115118
}
@@ -234,7 +237,7 @@ public void testGetGradeCode_shouldReturnData() {
234237
}
235238

236239
@Test
237-
public void testGetStudentRegistrationContacts_shouldReturnData() {
240+
public void testGetStudentRegistrationContacts_withExpiredContacts_shouldReturnData() {
238241
when(this.webClient.get()).thenReturn(this.requestHeadersUriMock);
239242
when(this.requestHeadersUriMock.uri(any(URI.class)))
240243
.thenReturn(this.requestHeadersMock);
@@ -246,10 +249,10 @@ public void testGetStudentRegistrationContacts_shouldReturnData() {
246249

247250
final var result = this.restUtils.getStudentRegistrationContactList("10200001");
248251
assertThat(result).hasSize(2);
249-
assertThat(result.get(0).getEmail()).isEqualTo("pen@email.com");
250-
assertThat(result.get(0).getFirstName()).isEqualTo("Joe");
251-
assertThat(result.get(1).getEmail()).isEqualTo("2@email.com");
252-
assertThat(result.get(1).getFirstName()).isEqualTo("2");
252+
assertThat(result.get(0).getEmail()).isEqualTo("active@email.com");
253+
assertThat(result.get(0).getFirstName()).isEqualTo("2");
254+
assertThat(result.get(1).getEmail()).isEqualTo("active@email.com");
255+
assertThat(result.get(1).getFirstName()).isEqualTo("Joe");
253256
}
254257

255258
private WebClient.RequestBodySpec returnMockBodySpec() {

0 commit comments

Comments
 (0)