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

build: update to Spring Boot 3.2 #253

Merged
merged 1 commit into from
Feb 28, 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
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
jacoco
`jvm-test-suite`
id("io.freefair.lombok") version "8.6"
id("org.springframework.boot") version "3.1.5"
id("org.springframework.boot") version "3.2.3"
id("io.spring.dependency-management") version "1.1.4"
id("org.graalvm.buildtools.native") version "0.10.1"
id("com.github.rising3.semver") version "0.8.2"
Expand All @@ -29,7 +29,7 @@ dependencies {
implementation("net.logstash.logback:logstash-logback-encoder:7.4")
implementation("ch.qos.logback:logback-classic")

implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.4"))
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2023.0.0"))

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
Expand Down Expand Up @@ -74,7 +74,7 @@ sonarqube {
}
}

extra["testcontainersVersion"] = "1.18.2"
extra["testcontainersVersion"] = "1.19.6"

// setup separate test suites for unit and integration tests
testing {
Expand Down
2 changes: 1 addition & 1 deletion compose/application.demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring:
uri: https://httpbin.org
order: 2
predicates:
- Host={tenant}.localtest.me:8080
- Host={tenant}.localtest.me

morp:
default-oauth2-client-registration: keycloak
Expand Down
8 changes: 4 additions & 4 deletions compose/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ spring:
uri: https://httpbin.org
order: 2
predicates:
- Host={tenant}.localtest.me:8080
- Host={tenant}.localtest.me
- id: host-mapping-with-stage
uri: https://httpbin.org
order: 1
predicates:
- Host={tenant}-{stage}.localtest.me:8080
- Host={tenant}-{stage}.localtest.me
- id: path-mapping
uri: https://httpbin.org
predicates:
Expand All @@ -26,8 +26,8 @@ spring:
- name: TenantFromHost
args:
patterns:
- static.localtest.me:8080
- another-static.localtest.me:8080
- static.localtest.me
- another-static.localtest.me
tenant: foo
- id: header-mapping
uri: https://httpbin.org
Expand Down
16 changes: 8 additions & 8 deletions mkdocs/docs/user-guide/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ tenant ID.
A tenant is how MORP names a customer, an application or a department. Each tenant is identified by a unique tenant ID.
To figure out the tenant for a request, MORP uses predicates. MORP supports the following predicates:

| Tenant Extractor | Example Configuration | Example Request | Example Tenant |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|----------------|
| `Host` | <pre>Host={tenant}.example.com</pre> | foo.example.com | foo |
| `Host` | <pre>Host={stage}-{tenant}.example.com | dev-foo.example.com | foo |
| `Path` | <pre>Path=example.com/tenant/{tenant}</pre> | example.com/tenant/foo | foo |
| `Path` | <pre>Path=example.com/api/{version}/tenant/{tenant}</pre> | example.com/api/v1/tenant/foo | foo |
| `TenantFromHost` | <pre>name: TenantFromHost<br/>args:<br/> patterns:<br/> - static.localtest.me:8080<br/> - another-static.localtest.me:8080<br/> tenant: foo</pre> | static.example.com | foo |
| `TenantFromHeader` | <pre>TenantFromHeader=X-Tenant-ID,{tenant}</pre> | X-Tenant-ID: foo | foo |
| Tenant Extractor | Example Configuration | Example Request | Example Tenant |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|----------------|
| `Host` | <pre>Host={tenant}.example.com</pre> | foo.example.com | foo |
| `Host` | <pre>Host={stage}-{tenant}.example.com | dev-foo.example.com | foo |
| `Path` | <pre>Path=example.com/tenant/{tenant}</pre> | example.com/tenant/foo | foo |
| `Path` | <pre>Path=example.com/api/{version}/tenant/{tenant}</pre> | example.com/api/v1/tenant/foo | foo |
| `TenantFromHost` | <pre>name: TenantFromHost<br/>args:<br/> patterns:<br/> - static.localtest.me<br/> - another-static.localtest.me<br/> tenant: foo</pre> | static.example.com | foo |
| `TenantFromHeader` | <pre>TenantFromHeader=X-Tenant-ID,{tenant}</pre> | X-Tenant-ID: foo | foo |

Predicates are configured in the `spring.cloud.gateway.routes[*].predicates` section and are applied per route. When no
tenant is extracted for a request, the request will fail.
Expand Down
4 changes: 2 additions & 2 deletions src/integrationTest/resources/morp/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spring:
- id: upstream-tenant-path
uri: http://upstream:1080
predicates:
- Host=morp:8081
- Host=morp
- Path=/upstream/{tenant}/{path}
filters:
- SetPath=/{path}
Expand All @@ -23,7 +23,7 @@ spring:
- id: upstream-tenant-host
uri: http://upstream:1080
predicates:
- Host={tenant}-morp:8081
- Host={tenant}-morp
- Path=/upstream/{path}
filters:
- SetPath=/{path}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/io/jaconi/morp/MorpApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@DisabledInAotMode
class MorpApplicationTests {

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.test.context.aot.DisabledInAotMode;
import reactor.test.StepVerifier;

import java.io.BufferedReader;
Expand All @@ -31,6 +32,7 @@
import static org.mockito.Mockito.when;

@SpringBootTest
@DisabledInAotMode
class MorpReactiveOAuth2UserServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.test.context.aot.DisabledInAotMode;
import reactor.test.StepVerifier;

import java.time.Instant;
Expand All @@ -27,6 +28,7 @@
import static org.mockito.Mockito.when;

@SpringBootTest
@DisabledInAotMode
class MorpReactiveOidcUserServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.test.context.aot.DisabledInAotMode;

import java.util.Map;
import java.util.Set;
Expand All @@ -16,6 +17,7 @@
import static org.mockito.Mockito.when;

@SpringBootTest
@DisabledInAotMode
class RegistrationResolverTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import org.springframework.cache.CacheManager;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.test.context.aot.DisabledInAotMode;
import reactor.test.StepVerifier;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;

@SpringBootTest
@DisabledInAotMode
class TenantAwareClientRegistrationRepositoryTest {

private static final String TENANT = "tenant1";
Expand Down