Skip to content
Open
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
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
grpcVersion=1.76.0


springBootVersion=3.5.7
springCloudVersion=2025.0.0
springBootVersion=4.0.0
springCloudVersion=2025.1.0

gradleErrorPronePluginVersion=3.0.1
errorProneVersion=2.16
lombokVersion=1.18.24
lombokVersion=1.18.38

version=5.2.1-SNAPSHOT
version=6.0.0-SNAPSHOT
group=io.github.lognet
description=Spring Boot starter for Google RPC.
gitHubUrl=https\://github.com/LogNet/grpc-spring-boot-starter
Expand All @@ -25,4 +25,4 @@ org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAME
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
30 changes: 15 additions & 15 deletions grpc-spring-boot-starter-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.lognet.springboot.grpc.gradle.ReactiveFeature

buildscript {
ext.kotlin_version = '1.9.10'
ext.kotlin_version = '2.1.21'
Comment thread
asinbow marked this conversation as resolved.
repositories {
mavenCentral()
}
Expand Down Expand Up @@ -80,6 +80,7 @@ dependencies {
implementation "org.springframework.security:spring-security-config"
implementation "org.springframework.security:spring-security-oauth2-jose"
implementation "org.springframework.security:spring-security-oauth2-resource-server"
implementation "org.springframework.boot:spring-boot-security"
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.springframework:spring-tx'

Expand All @@ -89,45 +90,51 @@ dependencies {
implementation project(':grpc-spring-boot-starter')
implementation project(':grpc-client-spring-boot-starter')

testImplementation 'org.springframework.boot:spring-boot-starter-aop'
testImplementation 'org.springframework.boot:spring-boot-starter-aspectj'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-resttestclient'
testImplementation 'com.github.stefanbirkner:system-rules:1.18.0'
testImplementation('org.springframework.cloud:spring-cloud-starter-consul-discovery')
testImplementation 'org.awaitility:awaitility:4.0.3'
testImplementation "org.springframework.cloud:spring-cloud-config-server"
testImplementation "org.springframework.cloud:spring-cloud-config-client"
testImplementation "org.springframework.cloud:spring-cloud-starter-bootstrap"

testImplementation "com.playtika.testcontainers:embedded-keycloak:3.1.11"
Comment thread
asinbow marked this conversation as resolved.
testImplementation "com.playtika.testcontainers:embedded-consul:3.1.11"
testImplementation "com.github.dasniko:testcontainers-keycloak:3.7.0"
testImplementation "com.playtika.testcontainers:embedded-consul:3.1.24"


testImplementation 'org.springframework.security:spring-security-core'
testImplementation "org.springframework.boot:spring-boot-security"
testImplementation "org.springframework.boot:spring-boot-security-oauth2-resource-server"
testImplementation "org.springframework.boot:spring-boot-validation"
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:2.23.0'


pureNettyTestImplementation "io.grpc:grpc-netty"


bothPureAndShadedNettyTestImplementation "io.grpc:grpc-netty:${grpcVersion}"

kafkaStreamTestImplementation "com.playtika.testcontainers:embedded-kafka:3.1.11"
kafkaStreamTestImplementation "com.playtika.testcontainers:embedded-kafka:3.1.24"
kafkaStreamTestImplementation "org.springframework.cloud:spring-cloud-starter-stream-kafka"

reactiveTestImplementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
reactiveTestImplementation 'org.postgresql:r2dbc-postgresql'
reactiveTestImplementation 'org.postgresql:postgresql'
reactiveTestImplementation "com.playtika.testcontainers:embedded-postgresql:3.1.11"
reactiveTestImplementation "com.playtika.testcontainers:embedded-postgresql:3.1.24"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"


}

configurations.all {
resolutionStrategy.eachDependency { details ->
if ("io.grpc".equalsIgnoreCase(details.requested.group)) {
details.useVersion grpcVersion
}
if ("org.testcontainers".equalsIgnoreCase(details.requested.group)) {
details.useVersion "1.20.6"
}
}
}

Expand All @@ -150,10 +157,3 @@ compileTestKotlin {
jvmTarget = JavaVersion.VERSION_17
}
}







Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CustomSecurityTest extends GrpcServerTestBase {
public static class DemoGrpcSecurityConfig extends GrpcSecurityConfigurerAdapter {

@Override
public void configure(GrpcSecurity builder) throws Exception {
public void configure(GrpcSecurity builder) {
builder.authorizeRequests()
.withSecuredAnnotation()
.authenticationSchemeSelector(scheme ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -23,7 +24,6 @@
import org.springframework.test.context.junit4.SpringRunner;

import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
Expand All @@ -32,7 +32,7 @@
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {DemoApp.class}, webEnvironment = NONE)
@ActiveProfiles({"disable-security", "kafka-test"})
@Import({GrpcKafkaTest.TestConfig.class})
@Import({GrpcKafkaTest.TestConfig.class, GrpcKafkaTest.ConsumerConfig.class})
public class GrpcKafkaTest extends GrpcServerTestBase {

@Configuration
Expand Down Expand Up @@ -60,18 +60,20 @@ public void custom(Custom.CustomRequest request, StreamObserver<Custom.CustomRep
).join();
}
}
}


@MockBean
public Consumer<String> consumerMock;
@TestConfiguration
public static class ConsumerConfig {
@Autowired
private Consumer<String> consumerMock;

@Bean
public Consumer<String> consumer() {
return consumerMock;
}
}

@Autowired
@MockitoBean
public Consumer<String> consumerMock;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import org.lognet.springboot.grpc.GrpcServerTestBase;
import org.lognet.springboot.grpc.demo.DemoApp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -27,6 +28,7 @@
, "spring.main.web-application-type=servlet"
})
@ActiveProfiles({"disable-security"})
@AutoConfigureTestRestTemplate
public class Issue295Test extends GrpcServerTestBase {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.lognet.springboot.grpc.auth.JwtAuthBaseTest;
import org.lognet.springboot.grpc.auth.KeycloakContainerInitializer;
import org.lognet.springboot.grpc.demo.DemoApp;
import org.lognet.springboot.rules.ExpectedStartupExceptionWithInspector;
import org.lognet.springboot.rules.SpringRunnerWithGlobalExpectedExceptionInspected;
Expand All @@ -12,6 +13,7 @@
import org.springframework.core.NestedExceptionUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;

import java.util.function.Predicate;

Expand All @@ -23,6 +25,7 @@
@RunWith(SpringRunnerWithGlobalExpectedExceptionInspected.class)
@SpringBootTest(classes = DemoApp.class)
@ActiveProfiles({"keycloack-test", "r2dbc-test", "reactive-buggy-security"})
@ContextConfiguration(initializers = KeycloakContainerInitializer.class)
@DirtiesContext
@ExpectedStartupExceptionWithInspector(BaggyReactiveSecurityTest.ExceptionInspector.class)
public class BaggyReactiveSecurityTest extends JwtAuthBaseTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.runner.RunWith;
import org.lognet.springboot.grpc.auth.JwtAuthBaseTest;
import org.lognet.springboot.grpc.auth.JwtRoleTest;
import org.lognet.springboot.grpc.auth.KeycloakContainerInitializer;
import org.lognet.springboot.grpc.demo.DemoApp;
import org.lognet.springboot.grpc.security.GrpcSecurity;
import org.lognet.springboot.grpc.security.GrpcSecurityConfigurerAdapter;
Expand All @@ -21,6 +22,7 @@
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Flux;

Expand All @@ -38,6 +40,7 @@
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DemoApp.class)
@ActiveProfiles({"keycloack-test", "r2dbc-test"})
@ContextConfiguration(initializers = KeycloakContainerInitializer.class)
@DirtiesContext
public class ReactiveDemoTest extends JwtAuthBaseTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.lognet.springboot.grpc.autoconfigure.GRpcAutoConfiguration;
import org.lognet.springboot.grpc.autoconfigure.security.SecurityAutoConfiguration;
import org.lognet.springboot.grpc.configserver.ConfigServerTestApplication;
import org.lognet.springboot.grpc.demo.DemoApp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
Expand Down Expand Up @@ -61,14 +58,12 @@ public static void startConfigServer(Properties properties ) throws IOException,
}


server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(ConfigServerTestApplication.class,
Comment thread
asinbow marked this conversation as resolved.
"--server.port=" + configPort,
"--spring.autoconfigure.exclude="+Stream.of(GRpcAutoConfiguration.class,
OAuth2ResourceServerAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class,
SecurityAutoConfiguration.class
)
.map(Class::getName).collect(Collectors.joining(",")),
"--spring.autoconfigure.exclude="+Stream.of(
"org.springframework.boot.security.oauth2.server.resource.autoconfigure.OAuth2ResourceServerAutoConfiguration",
"org.springframework.boot.security.autoconfigure.actuate.web.servlet.ManagementWebSecurityAutoConfiguration"
).collect(Collectors.joining(",")),
"--spring.cloud.consul.discovery.enabled=false",
"--spring.cloud.service-registry.enabled=false",
"--spring.cloud.service-registry.auto-registration.enabled=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public UserDetails user() {


@Override
public void configure(GrpcSecurity builder) throws Exception {
public void configure(GrpcSecurity builder) {


final UserDetails user = builder.getApplicationContext().getBean(UserDetails.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
Expand All @@ -37,7 +37,7 @@ public class GRpcServerBuilderConfigurerTest {
@Autowired
private GRpcServerBuilderConfigurer customGrpcServerBuilderConfigurer;

@MockBean(name = "anotherConfigurer")
@MockitoBean(name = "anotherConfigurer")
private GRpcServerBuilderConfigurer anotherConfigurer;

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -100,7 +100,7 @@ public Iterable<Tag> getTags(Status status, MethodDescriptor<?, ?> methodDescrip
}
}

@SpyBean
@MockitoSpyBean
private RequestAwareGRpcMetricsTagsContributor<GreeterOuterClass.Person> shouldNotBeInvoked;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.lognet.springboot.grpc.demo.DemoApp;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -46,10 +46,15 @@ public Status handle(Object message, Status status, Exception exception, Metadat
}
};
}

@Bean
public HalfCloseInterceptor halfCloseInterceptor() {
return new HalfCloseInterceptor();
}
Comment thread
asinbow marked this conversation as resolved.
}
private GreeterGrpc.GreeterBlockingStub stub;

@SpyBean
@MockitoSpyBean
HalfCloseInterceptor halfCloseInterceptor;

private static Locale systemDefaultLocale;
Expand Down
Loading
Loading