Skip to content

Commit 63990b6

Browse files
authored
Merge pull request #462 from RADAR-base/release-2.4.2
Release 2.4.2
2 parents c8c0439 + 7f37c89 commit 63990b6

File tree

87 files changed

+2606
-640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2606
-640
lines changed

.github/workflows/main.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Continuous integration, including test and integration test
22
name: CI
33

4-
# Run in master and dev branches and in all pull requests to those branches
4+
# Run in master and dev branches and in all pull requests to those branches, as well as on workflow dispatch for downstream testing
55
on:
6+
workflow_dispatch:
67
push:
78
branches: [ master, dev ]
89
pull_request:
@@ -33,13 +34,15 @@ jobs:
3334
- name: Compile code
3435
run: ./gradlew assemble
3536

37+
# Use 'docker compose' instead of 'docker-compose' to use v2
3638
- name: Setup docker services
3739
run: |
3840
sudo mkdir -p /usr/local/var/lib/radar/appserver/logs/
3941
sudo chown -R $(whoami) /usr/local/var/lib/radar/appserver/logs
40-
docker-compose -f src/integrationTest/resources/docker/docker-compose.yml up -d postgres managementportal
42+
docker compose -f src/integrationTest/resources/docker/non_appserver/docker-compose.yml up -d
4143
# Wait for services to start up.
4244
sleep 50
45+
4346
- name: Install gpg secret key
4447
run: |
4548
cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import
@@ -60,10 +63,52 @@ jobs:
6063
if-no-files-found: ignore
6164
retention-days: 5
6265

66+
# Build and test the code against the :dev docker image of parent repositories
67+
test-downstream:
68+
# The type of runner that the job will run on
69+
runs-on: ubuntu-latest
70+
# only run this on 'ready for review' PRs or when triggered by an upstream job
71+
if: github.event.pull_request.draft == false || github.event_name == 'workflow_dispatch'
72+
73+
# Steps represent a sequence of tasks that will be executed as part of the job
74+
steps:
75+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
76+
- uses: actions/checkout@v3
77+
78+
- uses: actions/setup-java@v3
79+
with:
80+
java-version: 17
81+
distribution: temurin
82+
83+
# Use 'docker compose' instead of 'docker-compose' to use v2
84+
- name: Setup docker services (:dev)
85+
run: |
86+
sudo mkdir -p /usr/local/var/lib/radar/appserver/logs/
87+
sudo chown -R $(whoami) /usr/local/var/lib/radar/appserver/logs
88+
# call docker compose without args to include the override file
89+
cd src/integrationTest/resources/docker/appserver_downstream
90+
docker compose up -d
91+
# Wait for services to start up.
92+
sleep 50
93+
94+
- name: Install gpg secret key
95+
run: |
96+
cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import
97+
gpg --list-secret-keys --keyid-format LONG
98+
99+
- name: Decrypt google application credentials
100+
run: |
101+
gpg --pinentry-mode loopback --local-user "Yatharth Ranjan" --batch --yes --passphrase "${{ secrets.GPG_SECRET_KEY_PASSPHRASE }}" --output src/integrationTest/resources/google-credentials.json --decrypt src/integrationTest/resources/google-credentials.enc.gpg
102+
103+
# Gradle check
104+
- name: Check
105+
run: GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/src/integrationTest/resources/google-credentials.json ./gradlew check
106+
63107
# Check that the docker image builds correctly
64108
docker:
65109
# The type of runner that the job will run on
66110
runs-on: ubuntu-latest
111+
if: github.event_name != 'workflow_dispatch'
67112

68113
# Steps represent a sequence of tasks that will be executed as part of the job
69114
steps:

README.md

Lines changed: 262 additions & 89 deletions
Large diffs are not rendered by default.

build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ apply plugin: 'io.spring.dependency-management'
1414
apply plugin: 'scala'
1515

1616
group = 'org.radarbase'
17-
version = '2.4.1'
17+
version = '2.4.2'
1818

1919
java {
2020
toolchain {
@@ -24,7 +24,6 @@ java {
2424

2525
repositories {
2626
mavenCentral()
27-
mavenLocal()
2827
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
2928
}
3029

@@ -39,9 +38,10 @@ ext {
3938
springDocVersion = '2.2.0'
4039
lombokVersion = '1.18.26'
4140
junit5Version = '5.9.2'
42-
radarSpringAuthVersion = '1.2.0'
41+
radarSpringAuthVersion = '1.2.1'
4342
springSecurityVersion = '6.0.2'
4443
hibernateValidatorVersion = '8.0.0.Final'
44+
minioVersion = '8.5.10'
4545
}
4646

4747
sourceSets {
@@ -61,10 +61,12 @@ dependencies {
6161
implementation('org.springframework.boot:spring-boot-starter-quartz')
6262
implementation('org.springframework.boot:spring-boot-starter-security')
6363
implementation('org.springframework.boot:spring-boot-starter-actuator')
64+
implementation('org.springframework.boot:spring-boot-starter-mail')
6465
implementation group: "org.springframework.security", name: "spring-security-config", version: springSecurityVersion
6566
implementation('org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:' + springBootVersion)
6667
implementation('org.springframework.security.oauth:spring-security-oauth2:' + springOauth2Version)
6768
runtimeOnly("org.hibernate.validator:hibernate-validator:$hibernateValidatorVersion")
69+
implementation("io.minio:minio:$minioVersion")
6870

6971
// Open API spec
7072
implementation(group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: springDocVersion)
@@ -207,3 +209,7 @@ tasks.named("dependencyUpdates").configure {
207209
isNonStable(it.candidate.version)
208210
}
209211
}
212+
213+
pmd {
214+
sourceSets = [sourceSets.main]
215+
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'appserver'
1+
rootProject.name = 'appserver'

src/integrationTest/java/org/radarbase/appserver/auth/NotificationEndpointAuthTest.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.springframework.http.HttpStatus;
5151
import org.springframework.http.ResponseEntity;
5252
import org.springframework.test.context.junit.jupiter.SpringExtension;
53+
import org.springframework.web.client.ResourceAccessException;
5354

5455
@ExtendWith(SpringExtension.class)
5556
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -158,20 +159,23 @@ public void unauthorisedCreateNotificationsForUser() {
158159
HttpEntity<FcmNotificationDto> notificationDtoHttpEntity =
159160
new HttpEntity<>(fcmNotificationDto, HEADERS);
160161

161-
ResponseEntity<FcmNotificationDto> notificationDtoResponseEntity =
162-
restTemplate.exchange(
163-
createURLWithPort(
164-
port,
165-
ProjectEndpointAuthTest.PROJECT_PATH
166-
+ UserEndpointAuthTest.DEFAULT_PROJECT
167-
+ UserEndpointAuthTest.USER_PATH
168-
+ DEFAULT_USER
169-
+ NOTIFICATION_PATH),
170-
HttpMethod.POST,
171-
notificationDtoHttpEntity,
172-
FcmNotificationDto.class);
173-
174-
assertEquals(HttpStatus.UNAUTHORIZED, notificationDtoResponseEntity.getStatusCode());
162+
ResponseEntity<FcmNotificationDto> notificationDtoResponseEntity = null;
163+
try {
164+
notificationDtoResponseEntity =
165+
restTemplate.exchange(
166+
createURLWithPort(
167+
port,
168+
ProjectEndpointAuthTest.PROJECT_PATH
169+
+ UserEndpointAuthTest.DEFAULT_PROJECT
170+
+ UserEndpointAuthTest.USER_PATH
171+
+ DEFAULT_USER
172+
+ NOTIFICATION_PATH),
173+
HttpMethod.POST,
174+
notificationDtoHttpEntity,
175+
FcmNotificationDto.class);
176+
} catch (ResourceAccessException e) {
177+
assertEquals(notificationDtoResponseEntity, null);
178+
}
175179
}
176180

177181
@Test
@@ -295,4 +299,4 @@ public void forbiddenViewNotificationsForOtherProject() {
295299

296300
assertEquals(HttpStatus.UNAUTHORIZED, notificationDtoResponseEntity.getStatusCode());
297301
}
298-
}
302+
}

src/integrationTest/java/org/radarbase/appserver/auth/ProjectEndpointAuthTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@
4141
import org.springframework.http.HttpStatus;
4242
import org.springframework.http.ResponseEntity;
4343
import org.springframework.test.context.junit.jupiter.SpringExtension;
44+
import org.springframework.web.client.ResourceAccessException;
4445

4546
@ExtendWith(SpringExtension.class)
4647
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
4748
@TestMethodOrder(OrderAnnotation.class)
49+
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
4850
public class ProjectEndpointAuthTest {
4951

5052
public static final String PROJECT_PATH = "/projects";
@@ -70,13 +72,17 @@ public void unauthorisedCreateProject() {
7072
ProjectDto projectDto = new ProjectDto().setProjectId("radar");
7173
HttpEntity<ProjectDto> projectEntity = new HttpEntity<>(projectDto, HEADERS);
7274

73-
ResponseEntity<ProjectDto> responseEntity =
74-
restTemplate.exchange(
75-
createURLWithPort(port, PROJECT_PATH),
76-
HttpMethod.POST,
77-
projectEntity,
78-
ProjectDto.class);
79-
assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode());
75+
ResponseEntity<ProjectDto> responseEntity = null;
76+
try {
77+
responseEntity =
78+
restTemplate.exchange(
79+
createURLWithPort(port, PROJECT_PATH),
80+
HttpMethod.POST,
81+
projectEntity,
82+
ProjectDto.class);
83+
} catch (ResourceAccessException e) {
84+
assertEquals(responseEntity, null);
85+
}
8086
}
8187

8288
@Test
@@ -167,4 +173,4 @@ public void getForbiddenProjectWithAuth() {
167173
// Access denied as the user has only access to the project that it is part of.
168174
assertEquals(HttpStatus.FORBIDDEN, responseEntity.getStatusCode());
169175
}
170-
}
176+
}

src/integrationTest/java/org/radarbase/appserver/auth/UserEndpointAuthTest.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.http.HttpStatus;
4747
import org.springframework.http.ResponseEntity;
4848
import org.springframework.test.context.junit.jupiter.SpringExtension;
49+
import org.springframework.web.client.ResourceAccessException;
4950

5051
@ExtendWith(SpringExtension.class)
5152
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -109,15 +110,18 @@ public void unauthorisedViewSingleUser() {
109110
public void unauthorisedCreateUser() {
110111
HttpEntity<FcmUserDto> userDtoHttpEntity = new HttpEntity<>(userDto, HEADERS);
111112

112-
ResponseEntity<FcmUserDto> responseEntity =
113-
restTemplate.exchange(
114-
createURLWithPort(
115-
port, ProjectEndpointAuthTest.PROJECT_PATH + DEFAULT_PROJECT + USER_PATH),
116-
HttpMethod.POST,
117-
userDtoHttpEntity,
118-
FcmUserDto.class);
119-
120-
assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode());
113+
ResponseEntity<FcmUserDto> responseEntity = null;
114+
try {
115+
responseEntity =
116+
restTemplate.exchange(
117+
createURLWithPort(
118+
port, ProjectEndpointAuthTest.PROJECT_PATH + DEFAULT_PROJECT + USER_PATH),
119+
HttpMethod.POST,
120+
userDtoHttpEntity,
121+
FcmUserDto.class);
122+
} catch (ResourceAccessException e) {
123+
assertEquals(responseEntity, null);
124+
}
121125
}
122126

123127
@Test
@@ -202,4 +206,4 @@ public void viewAllUsers() {
202206
// This should return a filtered list of users for which the token has access.
203207
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
204208
}
205-
}
209+
}

src/integrationTest/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spring.jpa.hibernate.ddl-auto=none
2525
spring.datasource.username=postgres
2626
spring.datasource.password=radar
2727
spring.datasource.url=jdbc:postgresql://localhost:5432/radar
28-
#jdbc:hsqldb:hsql://localhost:9001/appserver for running hsql separately in dev or testing
28+
# jdbc:hsqldb:hsql://localhost:9001/appserver for running hsql separately in dev or testing
2929
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
3030
spring.jpa.properties.hibernate.generate_statistics=false
3131
spring.jpa.properties.hibernate.jdbc.batch_size=20
@@ -87,7 +87,7 @@ spring.datasource.hikari.leakDetectionThreshold=120000
8787
# OAuth2 Resource Server Security
8888
security.oauth2.resource.id=res_AppServer
8989
security.radar.managementportal.enabled=true
90-
security.radar.managementportal.url=http://localhost:8081
90+
security.radar.managementportal.url=http://localhost:8081/managementportal
9191
# OAuth2 Client Security
9292
#security.oauth2.client.clientId=
9393
#security.oauth2.client.clientSecret=
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "3.8"
2+
3+
services:
4+
appserver:
5+
image: radarbase/radar-appserver
6+
build: ../../../..
7+
restart: always
8+
ports:
9+
- "8080:8080"
10+
volumes:
11+
- ../radar-is.yml:/resources/radar-is.yml
12+
- ../../../../logs/:/var/log/radar/appserver/
13+
environment:
14+
JDK_JAVA_OPTIONS: -Xmx4G -Djava.security.egd=file:/dev/./urandom
15+
FCMSERVER_SENDERID: "1043784930865"
16+
FCMSERVER_SERVERKEY: "AAAA8wZuFjE:APA91bGpJQ3Sft0mZAaVMjDJGNLjFsdDLTo-37ZN69r4lKlHiRN78t4bCfkNKcXG5c9cJg-eGtWB7FqceQUDVtf7B1Zvw_2ycynqwKe2YqXFeyaq83Gf0R3AS1EKSWFS60GCr8eUEliz"
17+
RADAR_ADMIN_USER: "radar"
18+
RADAR_ADMIN_PASSWORD: "radar"
19+
SPRING_APPLICATION_JSON: '{"spring":{"boot":{"admin":{"client":{"url":"http://spring-boot-admin:1111","username":"radar","password":"appserver"}}}}}'
20+
RADAR_IS_CONFIG_LOCATION: "/resources/radar-is.yml"
21+
SPRING_BOOT_ADMIN_CLIENT_INSTANCE_NAME: radar-appserver
22+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/radar
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# start the dockerstack using a prebuilt image pulled from dockerhub. This stack does not work without adding GOOGLE_APPLICATION_CREDENTIALS
2+
version: "3.8"
3+
4+
include:
5+
- "../non_appserver/docker-compose.yml"
6+
7+
services:
8+
appserver:
9+
extends:
10+
file: ../appserver.yml
11+
service: appserver
12+
networks:
13+
- db
14+
- default
15+
- admin

0 commit comments

Comments
 (0)