Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/pen 2107 #310

Merged
merged 6 commits into from
Sep 25, 2024
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 6 additions & 6 deletions .github/workflows/ci-api-build.and.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'
9 changes: 4 additions & 5 deletions .github/workflows/deploy-to.openshift-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = {
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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: |
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/deploy-to.openshift-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-to.openshift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tag-create.git.and.imagestream.tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -399,7 +401,10 @@ public List<SchoolContact> 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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand Down