diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..0a53f11d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/ci-api-build.and.test.yml b/.github/workflows/ci-api-build.and.test.yml index d188064a..2787f03c 100644 --- a/.github/workflows/ci-api-build.and.test.yml +++ b/.github/workflows/ci-api-build.and.test.yml @@ -25,14 +25,14 @@ jobs: working-directory: api steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: 17 distribution: oracle - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -41,7 +41,7 @@ jobs: - name: Run unit tests run: mvn -f pom.xml clean package - name: Cache SonarCloud packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar @@ -54,7 +54,7 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} - name: Run Trivy vulnerability scanner in repo mode - uses: aquasecurity/trivy-action@0.10.0 + uses: aquasecurity/trivy-action@0.24.0 with: scan-type: 'fs' ignore-unfixed: true @@ -63,6 +63,6 @@ jobs: severity: 'CRITICAL' - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: 'trivy-results.sarif' diff --git a/.github/workflows/deploy-to.openshift-dev.yml b/.github/workflows/deploy-to.openshift-dev.yml index ba74118f..188b5c4b 100644 --- a/.github/workflows/deploy-to.openshift-dev.yml +++ b/.github/workflows/deploy-to.openshift-dev.yml @@ -49,7 +49,6 @@ on: jobs: build-and-deploy-dev: name: Build and deploy to OpenShift DEV - # ubuntu-20.04 can also be used. runs-on: ubuntu-22.04 environment: dev @@ -59,7 +58,7 @@ jobs: steps: - name: Check for required secrets - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const secrets = { @@ -93,14 +92,14 @@ jobs: core.info(`✅ All the required secrets are set`); } - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Determine image tags if: env.IMAGE_TAGS == '' run: | echo "IMAGE_TAGS=latest ${GITHUB_SHA::12}" | tee -a $GITHUB_ENV - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.DOCKER_ARTIFACTORY_REPO }} username: ${{ secrets.DOCKER_HUB_USERNAME }} @@ -138,7 +137,7 @@ jobs: oc: 4 # https://github.com/redhat-actions/oc-login#readme - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Deploy API run: | diff --git a/.github/workflows/deploy-to.openshift-prod.yml b/.github/workflows/deploy-to.openshift-prod.yml index 1f02e5fb..527a9747 100644 --- a/.github/workflows/deploy-to.openshift-prod.yml +++ b/.github/workflows/deploy-to.openshift-prod.yml @@ -43,7 +43,6 @@ on: jobs: openshift-ci-cd: name: Deploy to OpenShift PROD - # ubuntu-20.04 can also be used. runs-on: ubuntu-22.04 environment: production @@ -53,7 +52,7 @@ jobs: steps: - name: Check for required secrets - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const secrets = { @@ -91,7 +90,7 @@ jobs: } - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get latest tag uses: actions-ecosystem/action-get-latest-tag@v1 @@ -103,7 +102,7 @@ jobs: oc: 4 # https://github.com/redhat-actions/oc-login#readme - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Deploy API run: | diff --git a/.github/workflows/deploy-to.openshift-test.yml b/.github/workflows/deploy-to.openshift-test.yml index 06c71389..69fec820 100644 --- a/.github/workflows/deploy-to.openshift-test.yml +++ b/.github/workflows/deploy-to.openshift-test.yml @@ -60,7 +60,7 @@ jobs: steps: - name: Check for required secrets - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const secrets = { @@ -98,7 +98,7 @@ jobs: } - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install oc uses: redhat-actions/openshift-tools-installer@v1 diff --git a/.github/workflows/tag-create.git.and.imagestream.tag.yml b/.github/workflows/tag-create.git.and.imagestream.tag.yml index 57b1f8a8..64c6cb6f 100644 --- a/.github/workflows/tag-create.git.and.imagestream.tag.yml +++ b/.github/workflows/tag-create.git.and.imagestream.tag.yml @@ -33,10 +33,10 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Create tag - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | github.rest.git.createRef({ @@ -52,7 +52,7 @@ jobs: oc: 4 # https://github.com/redhat-actions/oc-login#readme - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Tag in OpenShift run: | set -eux diff --git a/api/src/main/java/ca/bc/gov/educ/penreg/api/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/penreg/api/rest/RestUtils.java index cc7fcf76..758d1689 100644 --- a/api/src/main/java/ca/bc/gov/educ/penreg/api/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/penreg/api/rest/RestUtils.java @@ -14,6 +14,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Sets; +import java.time.*; +import java.time.format.*; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -399,7 +401,10 @@ public List getStudentRegistrationContactList(final String mincod throw new PenRegAPIRuntimeException("API call to Institute API received null response when getting student registration contacts, contact the Ministry for more info."); } - return schoolContactSearchWrapper.getContent(); + return schoolContactSearchWrapper.getContent().stream().filter(contact -> { + final String expiryDate = contact.getExpiryDate(); + return contact.getExpiryDate() == null || (expiryDate != null && LocalDate.parse(expiryDate, DateTimeFormatter.ISO_DATE_TIME).isAfter(LocalDate.now())); + }).toList(); }catch(Exception e){ log.error("API call to Institute API failure getting student registration contacts :: {}", e.getMessage()); throw new PenRegAPIRuntimeException("API call to Institute API failure getting student registration contacts, contact the Ministry for more info."); diff --git a/api/src/test/java/ca/bc/gov/educ/penreg/api/batch/processor/PenRegBatchProcessorTest.java b/api/src/test/java/ca/bc/gov/educ/penreg/api/batch/processor/PenRegBatchProcessorTest.java index 9f8b9ca5..1da551c1 100644 --- a/api/src/test/java/ca/bc/gov/educ/penreg/api/batch/processor/PenRegBatchProcessorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/penreg/api/batch/processor/PenRegBatchProcessorTest.java @@ -713,7 +713,7 @@ public void testProcessPenRegBatchFileFromTSW_GivenmincodeInvalidSchoolCloseDate @Transactional public void testProcessPenRegBatchFileFromTSW_GivenmincodeInvalidSchoolOpenDate_ShouldCreateRecordLOADFAILInDB() throws IOException { final School school = this.createMockSchool(); - school.setOpenedDate("2024-09-01T00:00:00"); + school.setOpenedDate(LocalDateTime.now().plusYears(1).toString()); when(this.restUtils.getSchoolByMincode(anyString())).thenReturn(Optional.of(school)); final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("sample_5_K12_OK.txt")).getFile()); final byte[] bFile = Files.readAllBytes(file.toPath()); diff --git a/api/src/test/java/ca/bc/gov/educ/penreg/api/rest/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/penreg/api/rest/RestUtilsTest.java index 30612bd2..2cbaa479 100644 --- a/api/src/test/java/ca/bc/gov/educ/penreg/api/rest/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/penreg/api/rest/RestUtilsTest.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.nats.client.Message; import java.net.*; +import java.time.*; import java.util.*; import lombok.val; import org.junit.Before; @@ -108,8 +109,10 @@ private GradeCode[] createGradeCodeArray() { private SchoolContactSearchWrapper createSchoolContactSearchWrapper() { SchoolContactSearchWrapper schoolSearchWrapper = new SchoolContactSearchWrapper(); - schoolSearchWrapper.setContent(Arrays.asList(SchoolContact.builder().email("pen@email.com").firstName("Joe").lastName("Blow").build(), - SchoolContact.builder().email("2@email.com").firstName("2").lastName("2").build())); + schoolSearchWrapper.setContent(Arrays.asList( + SchoolContact.builder().email("expired@email.com").firstName("Joe").lastName("Blow").expiryDate(LocalDateTime.now().minusDays(1).toString()).build(), + SchoolContact.builder().email("active@email.com").firstName("2").lastName("2").expiryDate(null).build(), + SchoolContact.builder().email("active@email.com").firstName("Joe").lastName("Blow").expiryDate(LocalDateTime.now().plusDays(1).toString()).build())); return schoolSearchWrapper; } @@ -234,7 +237,7 @@ public void testGetGradeCode_shouldReturnData() { } @Test - public void testGetStudentRegistrationContacts_shouldReturnData() { + public void testGetStudentRegistrationContacts_withExpiredContacts_shouldReturnData() { when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(any(URI.class))) .thenReturn(this.requestHeadersMock); @@ -246,10 +249,10 @@ public void testGetStudentRegistrationContacts_shouldReturnData() { final var result = this.restUtils.getStudentRegistrationContactList("10200001"); assertThat(result).hasSize(2); - assertThat(result.get(0).getEmail()).isEqualTo("pen@email.com"); - assertThat(result.get(0).getFirstName()).isEqualTo("Joe"); - assertThat(result.get(1).getEmail()).isEqualTo("2@email.com"); - assertThat(result.get(1).getFirstName()).isEqualTo("2"); + assertThat(result.get(0).getEmail()).isEqualTo("active@email.com"); + assertThat(result.get(0).getFirstName()).isEqualTo("2"); + assertThat(result.get(1).getEmail()).isEqualTo("active@email.com"); + assertThat(result.get(1).getFirstName()).isEqualTo("Joe"); } private WebClient.RequestBodySpec returnMockBodySpec() {