Skip to content

Commit 7cdc632

Browse files
authored
Merge pull request #26 from KPMP/develop
Release v2.2
2 parents 1e583ec + a1fc50d commit 7cdc632

File tree

9 files changed

+104
-68
lines changed

9 files changed

+104
-68
lines changed

.github/workflows/build-gradle-project.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
build-gradle-project:
88
env:
9-
IMAGE_TAG: 2.1
9+
IMAGE_TAG: 2.2
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Get branch names
@@ -21,12 +21,12 @@ jobs:
2121
uses: actions/checkout@v3
2222
- uses: actions/setup-java@v3
2323
with:
24-
java-version: '8'
24+
java-version: '21'
2525
distribution: 'temurin'
2626
- name: Setup Gradle
2727
uses: gradle/gradle-build-action@v2
2828
with:
29-
gradle-version: 7.4
29+
gradle-version: 8.5
3030

3131
- name: Login to Docker Hub
3232
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"java.compile.nullAnalysis.mode": "automatic",
3+
"java.configuration.updateBuildConfiguration": "interactive"
4+
}

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
FROM alpine
1+
FROM alpine:3.20.0
22

33
RUN apk update && \
44
apk upgrade
5-
RUN apk add openjdk8
6-
7-
RUN apk add --no-cache tzdata
8-
RUN cp /usr/share/zoneinfo/America/Detroit /etc/localtime
9-
RUN echo "America/Detroit" > /etc/timezone
5+
RUN apk add openjdk21
106

117
VOLUME /tmp
128
ARG DEPENDENCY=target/dependency
@@ -15,4 +11,8 @@ COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
1511
COPY ${DEPENDENCY}/META-INF /app/META-INF
1612
COPY ${DEPENDENCY}/BOOT-INF/classes /app
1713

18-
ENTRYPOINT ["java","-cp","app:app/lib/*","org.kpmp.Application"]
14+
RUN apk add --no-cache tzdata
15+
ENV TZ=America/Detroit
16+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
17+
18+
ENTRYPOINT ["java", "-cp","app:app/lib/*","org.kpmp.Application"]

build.gradle

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
buildscript {
2-
ext {
3-
springBootVersion = '2.7.4'
4-
}
5-
repositories {
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10-
}
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath("org.springframework.boot:spring-boot-gradle-plugin:3.2.5")
7+
}
118
}
129

1310
plugins {
14-
id 'com.palantir.docker' version '0.22.1'
11+
id 'java'
12+
id 'com.palantir.docker' version '0.35.0'
13+
id 'org.springframework.boot' version '3.2.5'
1514
}
1615

1716
group = 'kingstonduo'
@@ -21,30 +20,27 @@ apply plugin: 'org.springframework.boot'
2120
apply plugin: 'io.spring.dependency-management'
2221
apply plugin: 'eclipse'
2322

24-
sourceCompatibility = '1.8'
25-
targetCompatibility = '1.8'
23+
sourceCompatibility = '21'
24+
targetCompatibility = '21'
2625

2726
repositories {
2827
mavenCentral()
2928
}
3029

3130
dependencies {
32-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
33-
implementation 'com.auth0:java-jwt:3.18.3'
31+
implementation 'com.auth0:java-jwt:4.4.0'
3432
implementation 'org.springframework.boot:spring-boot-starter-web'
35-
implementation 'org.jsoup:jsoup:1.15.3'
36-
testImplementation 'junit:junit:4.12'
33+
implementation 'org.jsoup:jsoup:1.18.3'
34+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
35+
testImplementation('org.mockito:mockito-junit-jupiter:3.12.4')
3736
}
3837

38+
version='2.2'
39+
3940
springBoot {
4041
mainClass = "org.kpmp.Application"
4142
}
4243

43-
jar {
44-
baseName='user-auth'
45-
version='2.1'
46-
}
47-
4844
task unpack(type: Copy) {
4945
dependsOn bootJar
5046
from(zipTree(tasks.bootJar.outputs.files.singleFile))
@@ -67,15 +63,15 @@ def getCurrentGitBranch() {
6763
} catch (e) {
6864
}
6965
if (gitBranch == "develop" || gitBranch == "master"){
70-
return jar.version
66+
return project.version
7167
}else{
7268
return gitBranch
7369
}
7470
}
7571
}
7672

7773
docker {
78-
name "kingstonduo/${jar.baseName}:" + getCurrentGitBranch()
74+
name "kingstonduo/user-auth:" + getCurrentGitBranch()
7975
copySpec.from(tasks.unpack.outputs).into("dependency")
8076
buildArgs(['DEPENDENCY': "dependency"])
8177
}

changelog.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
# Changelog
22

3-
## Release 2.1 [unreleased]
3+
## Release 2.2 [unreleased]
44
Brief summary of what's in this release:
5+
- Upgrade to Java 21
56

7+
### Breaking changes
8+
9+
Breaking changes include any database updates needed, if we need to edit any files on system (like .env or certs, etc). Things that are outside of the code itself that need changed for the system to work.
10+
11+
12+
### Non-breaking changes
13+
14+
Just a place to keep track of things that have changed in the code that we may want to pay special attention to when smoke testing, etc.
15+
16+
---
17+
18+
## Release 2.1 [released 10/16/2024]
19+
Brief summary of what's in this release:
20+
- addressed vulnerabilities
21+
- introduced build action to push image to docker hub
22+
- introduction of changelog
623

724
### Breaking changes
825

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/org/kpmp/auth/AuthController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class AuthController {
2222
private static final String userNotFoundFmt = "Using default client. User with shib id {} not found";
2323
private static final String userClientFoundFmt = "Using client ID {}. User with shib id {} found: {}";
2424
private static final String userClientNotFoundFmt = "Using client ID {}. User with shib id {} not found";
25-
private static final String portalError = "There was a problem connecting to the User Portal. ";
25+
private static final String portalError = "There was a problem connecting to the User Portal.";
2626

2727
private UserPortalService userPortalService;
2828

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
package org.kpmp.auth;
22

3-
import org.junit.After;
4-
import org.junit.Before;
5-
import org.junit.Rule;
6-
import org.junit.Test;
7-
import org.junit.rules.ExpectedException;
83
import org.mockito.Mock;
94
import org.mockito.MockitoAnnotations;
105
import org.springframework.http.HttpStatus;
116
import org.springframework.web.client.HttpClientErrorException;
127
import org.springframework.web.server.ResponseStatusException;
138

14-
import static org.junit.Assert.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.assertThrows;
11+
import static org.mockito.Mockito.verify;
1512
import static org.mockito.Mockito.when;
1613

14+
import org.junit.jupiter.api.AfterEach;
15+
import org.junit.jupiter.api.BeforeEach;
16+
import org.junit.jupiter.api.Test;
17+
1718
public class AuthControllerTest {
1819

1920
@Mock
2021
private UserPortalService userPortalService;
2122
private AuthController authController;
2223

23-
@Rule
24-
public final ExpectedException exception = ExpectedException.none();
25-
26-
@Before
24+
@BeforeEach
2725
public void setUp() throws Exception {
28-
MockitoAnnotations.initMocks(this);
26+
MockitoAnnotations.openMocks(this);
2927
authController = new AuthController(userPortalService);
3028
}
3129

32-
@After
30+
@AfterEach
3331
public void tearDown() throws Exception {
3432
authController = null;
3533
}
@@ -45,18 +43,30 @@ public void testGetUserAuth() throws Exception {
4543

4644
@Test
4745
public void testGetUserAuthNotFound() {
48-
when(userPortalService.getUserAuth("shibId")).thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
49-
exception.expect(ResponseStatusException.class);
50-
exception.expectMessage("User shibId not found");
51-
authController.getUserInfo("shibId");
46+
String shibId = "shibId";
47+
when(userPortalService.getUserAuth(shibId)).thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
48+
49+
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> {
50+
authController.getUserInfo(shibId);
51+
});
52+
53+
assertEquals(HttpStatus.NOT_FOUND, exception.getStatusCode());
54+
assertEquals("User " + shibId + " not found", exception.getReason());
55+
56+
verify(userPortalService).getUserAuth(shibId);
5257
}
5358

5459
@Test
5560
public void testUserPortalProblem() {
5661
when(userPortalService.getUserAuth("shibId")).thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR));
57-
exception.expect(ResponseStatusException.class);
58-
exception.expectMessage("There was a problem connecting to the User Portal");
59-
authController.getUserInfo("shibId");
62+
63+
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> {
64+
authController.getUserInfo("shibId");
65+
});
66+
67+
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, exception.getStatusCode());
68+
assertEquals("There was a problem connecting to the User Portal.", exception.getReason());
69+
verify(userPortalService).getUserAuth("shibId");
6070
}
6171

6272
@Test
@@ -71,17 +81,25 @@ public void testGetUserAuthWithClient() throws Exception {
7181
@Test
7282
public void testGetUserAuthWithClientNotFound() {
7383
when(userPortalService.getUserAuthWithClient("clientId", "shibId")).thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
74-
exception.expect(ResponseStatusException.class);
75-
exception.expectMessage("User not found");
76-
authController.getUserInfoWithClient("clientId", "shibId");
84+
85+
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> {
86+
authController.getUserInfoWithClient("clientId", "shibId");
87+
});
88+
assertEquals(HttpStatus.NOT_FOUND, exception.getStatusCode());
89+
assertEquals("User not found", exception.getReason());
90+
verify(userPortalService).getUserAuthWithClient("clientId", "shibId");
7791
}
7892

7993
@Test
8094
public void testGetUserAuthWithClientPortalProblem() {
8195
when(userPortalService.getUserAuthWithClient("clientId", "shibId")).thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR));
82-
exception.expect(ResponseStatusException.class);
83-
exception.expectMessage("There was a problem connecting to the User Portal");
84-
authController.getUserInfoWithClient("clientId", "shibId");
96+
97+
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> {
98+
authController.getUserInfoWithClient("clientId", "shibId");
99+
});
100+
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, exception.getStatusCode());
101+
assertEquals("There was a problem connecting to the User Portal.", exception.getReason());
102+
verify(userPortalService).getUserAuthWithClient("clientId", "shibId");
85103
}
86104

87105
}

src/test/java/org/kpmp/auth/UserAuthTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package org.kpmp.auth;
22

3-
import static org.junit.Assert.assertArrayEquals;
4-
import static org.junit.Assert.assertEquals;
53

6-
import org.junit.After;
7-
import org.junit.Before;
8-
import org.junit.Test;
4+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
import org.junit.jupiter.api.AfterEach;
8+
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.Test;
910

1011
public class UserAuthTest {
1112

1213
private UserAuth testUserAuth;
1314

14-
@Before
15+
@BeforeEach
1516
public void setUp() throws Exception {
1617
testUserAuth = new UserAuth();
1718
}
1819

19-
@After
20+
@AfterEach
2021
public void tearDown() throws Exception {
2122
testUserAuth = null;
2223
}

0 commit comments

Comments
 (0)