Merge pull request #99 from spring-cloud/boot3-compat-no-2

Spring Boot 3 Compatibility on main branch
This commit is contained in:
Anthony Dahanne
2023-06-22 10:41:58 -04:00
committed by GitHub
118 changed files with 633 additions and 445 deletions

188
README.md
View File

@@ -3,6 +3,12 @@ The Spring Cloud Bindings library exposes a rich Java language binding for the [
[s]: https://github.com/servicebinding/spec
## Features
* Java 17
* Spring Boot 3
For Spring Boot 2 compatibility, please have a look at the [1.x releases](https://github.com/spring-cloud/spring-cloud-bindings/tree/1.x).
## Library Usage
While less used, explicit binding access can be achieved through the `Bindings` type.
@@ -38,12 +44,13 @@ Each auto-configuration is triggered by the type of binding. Each auto-configur
Type: `artemis`
Disable Property: `org.springframework.cloud.bindings.boot.artemis.enable`
#### Properties
| Property | Value |
| --------------------------------------------------- | -------------------------------------- |
| `spring.artemis.host` | `{host}` |
| `spring.artemis.broker-url` | `{broker-url}` |
| `spring.artemis.mode` | `{mode}` |
| `spring.artemis.password` | `{password}` |
| `spring.artemis.port` | `{port}` |
| `spring.artemis.user` | `{user}` |
| `spring.artemis.embedded.cluster-password` | `{embedded.cluster-password}` |
| `spring.artemis.embedded.data-directory` | `{embedded.data-directory}` |
@@ -65,30 +72,35 @@ Disable Property: `org.springframework.cloud.bindings.boot.artemis.enable`
Type: `cassandra`
Disable Property: `org.springframework.cloud.bindings.boot.cassandra.enable`
| Property | Value |
| -------------------------------------- | ------------------ |
| `spring.data.cassandra.cluster-name` | `{cluster-name}` |
| `spring.data.cassandra.compression` | `{compression}` |
| `spring.data.cassandra.contact-points` | `{contact-points}` |
| `spring.data.cassandra.keyspace-name` | `{keyspace-name}` |
| `spring.data.cassandra.password` | `{password}` |
| `spring.data.cassandra.port` | `{port}` |
| `spring.data.cassandra.ssl` | `{ssl}` |
| `spring.data.cassandra.username` | `{username}` |
#### Properties
| Property | Value |
|--------------------------------------------------------------|-----------------------------------------------|
| `spring.cassandra.cluster-name` | `{cluster-name}` |
| `spring.cassandra.compression` | `{compression}` |
| `spring.cassandra.contact-points` | `{contact-points}` |
| `spring.cassandra.keyspace-name` | `{keyspace-name}` |
| `spring.cassandra.password` | `{password}` |
| `spring.cassandra.port` | `{port}` |
| `spring.cassandra.ssl` | `{ssl}` |
| `spring.cassandra.username` | `{username}` |
| `spring.cassandra.request.throttler.drain-interval` | `{request.throttler.drain-interval}` |
| `spring.cassandra.request.throttler.max-concurrent-requests` | `{request.throttler.max-concurrent-requests}` |
| `spring.cassandra.request.throttler.max-queue-size` | `{request.throttler.max-queue-size}` |
| `spring.cassandra.request.throttler.max-requests-per-second` | `{request.throttler.max-requests-per-second}` |
### Couchbase
Type: `couchbase`
Disable Property: `org.springframework.cloud.bindings.boot.couchbase.enable`
| Property | Value |
| ------------------------------------------------- | ---------------------------------- |
| `spring.couchbase.bootstrap-hosts` | `{bootstrap-hosts}` |
| `spring.couchbase.bucket.name` | `{bucket.name}` |
| `spring.couchbase.bucket.password` | `{bucket.passsword}` |
| `spring.couchbase.env.bootstrap.http-direct-port` | `{env.bootstrap.http-direct-port}` |
| `spring.couchbase.env.bootstrap.http-ssl-port` | `{env.bootstrap.http-ssl-port}` |
| `spring.couchbase.password` | `{password}` |
| `spring.couchbase.username` | `{username}` |
#### Properties
| Property | Value |
|--------------------------------------------------|---------------------------|
| `spring.couchbase.connection-string` | `{connection-string}` |
| `spring.data.couchbase.bucket-name` | `{bucket-name}` |
| `spring.couchbase.password` | `{password}` |
| `spring.couchbase.username` | `{username}` |
### DB2 RDBMS
Type: `db2`
@@ -109,19 +121,13 @@ Disable Property: `org.springframework.cloud.bindings.boot.db2.enable`
Type: `elasticsearch`
Disable Property: `org.springframework.cloud.bindings.boot.elasticsearch.enable`
| Property | Value |
| ----------------------------------------------------- | -------------- |
| `spring.data.elasticsearch.client.reactive.endpoints` | `{endpoints}` |
| `spring.data.elasticsearch.client.reactive.password` | `{password}` |
| `spring.data.elasticsearch.client.reactive.use-ssl` | `{use-ssl}` |
| `spring.data.elasticsearch.client.reactive.username` | `{username}` |
| `spring.elasticsearch.jest.password` | `{password}` |
| `spring.elasticsearch.jest.proxy.host` | `{proxy.host}` |
| `spring.elasticsearch.jest.proxy.port` | `{proxy.port}` |
| `spring.elasticsearch.jest.username` | `{username}` |
| `spring.elasticsearch.rest.password` | `{password}` |
| `spring.elasticsearch.rest.uris` | `{uris}` |
| `spring.elasticsearch.rest.username` | `{username}` |
#### Properties
| Property | Value |
|---------------------------------|---------------|
| `spring.elasticsearch.password` | `{password}` |
| `spring.elasticsearch.uris` | `{uris}` |
| `spring.elasticsearch.username` | `{username}` |
### Kafka
Type: `kafka`
@@ -180,11 +186,13 @@ Disable Property: `org.springframework.cloud.bindings.boot.mysql.enable`
Type: `neo4j`
Disable Property: `org.springframework.cloud.bindings.boot.neo4j.enable`
| Property | Value |
| ---------------------------- | ------------ |
| `spring.data.neo4j.password` | `{password}` |
| `spring.data.neo4j.uri` | `{uri}` |
| `spring.data.neo4j.username` | `{username}` |
#### Properties
| Property | Value |
|-----------------------------------------|----------------|
| `spring.neo4j.uri` | `{uri}` |
| `spring.neo4j.authentication.username` | `{username}` |
| `spring.neo4j.authentication.password` | `{password}` |
### Oracle RDBMS
Type: `oracle`
@@ -231,19 +239,21 @@ Disable Property: `org.springframework.cloud.bindings.boot.rabbitmq.enable`
Type: `redis`
Disable Property: `org.springframework.cloud.bindings.boot.redis.enable`
| Property | Value |
| ------------------------------------ | ------------------------- |
| `spring.redis.client-name` | `{client-name}` |
| `spring.redis.cluster.max-redirects` | `{cluster.max-redirects}` |
| `spring.redis.cluster.nodes` | `{cluster.nodes}` |
| `spring.redis.database` | `{database}` |
| `spring.redis.host` | `{host}` |
| `spring.redis.password` | `{password}` |
| `spring.redis.port` | `{port}` |
| `spring.redis.sentinel.master` | `{sentinel.master}` |
| `spring.redis.sentinel.nodes` | `{sentinel.nodes}` |
| `spring.redis.ssl` | `{ssl}` |
| `spring.redis.url` | `{url}` |
#### Properties
| Property | Value |
|-------------------------------------------|---------------------------|
| `spring.data.redis.client-name` | `{client-name}` |
| `spring.data.redis.cluster.max-redirects` | `{cluster.max-redirects}` |
| `spring.data.redis.cluster.nodes` | `{cluster.nodes}` |
| `spring.data.redis.database` | `{database}` |
| `spring.data.redis.host` | `{host}` |
| `spring.data.redis.password` | `{password}` |
| `spring.data.redis.port` | `{port}` |
| `spring.data.redis.sentinel.master` | `{sentinel.master}` |
| `spring.data.redis.sentinel.nodes` | `{sentinel.nodes}` |
| `spring.data.redis.ssl` | `{ssl}` |
| `spring.data.redis.url` | `{url}` |
### SAP Hana
Type: `hana`
@@ -338,6 +348,7 @@ Type: `vault`
Disable Property: `org.springframework.cloud.bindings.boot.vault.enable`
Any Provider:
| Property | Value |
| ----------------------------------- | ------------------------- |
| `spring.cloud.vault.authentication` | `{authentication-method}` |
@@ -345,6 +356,7 @@ Any Provider:
| `spring.cloud.vault.uri` | `{uri}` |
If `{authentication-method}` is equal to `approle`:
| Property | Value |
| ------------------------------------------- | ----------------- |
| `spring.cloud.vault.app-role.app-role-path` | `{app-role-path}` |
@@ -353,6 +365,7 @@ If `{authentication-method}` is equal to `approle`:
| `spring.cloud.vault.app-role.secret-id` | `{secret-id}` |
If `{authentication-method}` is equal to `aws_ec2`:
| Property | Value |
| ---------------------------------------------- | -------------------------------------- |
| `spring.cloud.vault.aws-ec2.aws-ec2-path` | `{aws-ec2-path}` |
@@ -361,57 +374,70 @@ If `{authentication-method}` is equal to `aws_ec2`:
| `spring.cloud.vault.aws-ec2.role` | `{role}` |
If `{authentication-method}` is equal to `aws_iam`:
| Property | Value |
| ----------------------------------------- | ------------------------ |
| `spring.cloud.vault.aws-iam.aws-path` | `{aws-path}` |
| `spring.cloud.vault.aws-iam.endpoint-uri` | `{aws-sts-endpoint-uri}` |
| `spring.cloud.vault.aws-iam.role` | `{role}` |
| `spring.cloud.vault.aws-iam.server-id` | `{aws-iam-server-id}` |
| Property | Value |
|-------------------------------------------|----------------------------------------|
| `spring.cloud.vault.aws-iam.aws-path` | `{aws-path}` |
| `spring.cloud.vault.aws-iam.endpoint-uri` | `{aws-sts-endpoint-uri}` |
| `spring.cloud.vault.aws-iam.role` | `{role}` |
| `spring.cloud.vault.aws-iam.server-name` | `{aws-iam-server-name}` |
If `{authentication-method}` is equal to `azure_msi`:
| Property | Value |
| ----------------------------------------- | -------------- |
| `spring.cloud.vault.azure-msi.azure-path` | `{azure-path}` |
| `spring.cloud.vault.azure-msi.role` | `{role}` |
| Property | Value |
|-------------------------------------------------------|------------------------------------------|
| `spring.cloud.vault.azure-msi.azure-path` | `{azure-path}` |
| `spring.cloud.vault.azure-msi.role` | `{role}` |
| `spring.cloud.vault.azure-msi.metadata-service` | `{metadata-service}` |
| `spring.cloud.vault.azure-msi.identity-token-service` | `{identity-token-service}` |
If `{authentication-method}` is equal to `cert`:
| Property | Value |
| ------------------------------------------- | --------------------------------------------- |
| `spring.cloud.vault.ssl.cert-auth-path` | `{cert-auth-path}` |
| `spring.cloud.vault.ssl.key-store-password` | `{key-store-password}` |
| `spring.cloud.vault.ssl.key-store` | `${SERVICE_BINDING_ROOT}/{name}/keystore.jks` |
| Property | Value |
|-----------------------------------------------|---------------------------------------------------------------|
| `spring.cloud.vault.ssl.cert-auth-path` | `{cert-auth-path}` |
| `spring.cloud.vault.ssl.key-store-password` | `{key-store-password}` |
| `spring.cloud.vault.ssl.key-store` | `${SERVICE_BINDING_ROOT}/{name}/keystore.jks` |
| `spring.cloud.vault.ssl.trust-store` | `${SERVICE_BINDING_ROOT}/{name}/truststore.jks` |
| `spring.cloud.vault.ssl.trust-store-password` | `{trust-store-password}` |
If `{authentication-method}` is equal to `cubbyhole`:
| Property | Value |
| -------------------------- | --------- |
| `spring.cloud.vault.token` | `{token}` |
If `{authentication-method}` is equal to `gcp_gce`:
| Property | Value |
| -------------------------------------------- | ----------------------- |
| `spring.cloud.vault.gcp-gce.gcp-path` | `{gcp-path}` |
| `spring.cloud.vault.gcp-gce.role` | `{role}` |
| `spring.cloud.vault.gcp-gce.service-account` | `{gcp-service-account}` |
If `{authentication-method}` is equal to `gcp_iam`:
| Property | Value |
| ---------------------------------------------------- | ------------------------------------------------- |
| `spring.cloud.vault.gcp-iam.credentials.encoded-key` | `{encoded-key}` |
| `spring.cloud.vault.gcp-iam.credentials.location` | `${SERVICE_BINDING_ROOT}/{name}/credentials.json` |
| `spring.cloud.vault.gcp-iam.gcp-path` | `{gcp-path}` |
| `spring.cloud.vault.gcp-iam.jwt-validity` | `{jwt-validity}` |
| `spring.cloud.vault.gcp-iam.project-id` | `{gcp-project-id}` |
| `spring.cloud.vault.gcp-iam.role` | `{role}` |
| `spring.cloud.vault.gcp-iam.service-account` | `{gcp-service-account}` |
| Property | Value |
|------------------------------------------------------|----------------------------------------------------|
| `spring.cloud.vault.gcp-iam.credentials.encoded-key` | `{encoded-key}` |
| `spring.cloud.vault.gcp-iam.credentials.location` | `${SERVICE_BINDING_ROOT}/{name}/credentials.json` |
| `spring.cloud.vault.gcp-iam.gcp-path` | `{gcp-path}` |
| `spring.cloud.vault.gcp-iam.jwt-validity` | `{jwt-validity}` |
| `spring.cloud.vault.gcp-iam.project-id` | `{gcp-project-id}` |
| `spring.cloud.vault.gcp-iam.role` | `{role}` |
| `spring.cloud.vault.gcp-iam.service-account` | `{gcp-service-account}` Spring Boot 2 |
| `spring.cloud.vault.gcp-iam.service-account-id` | `{gcp-service-account}` Spring Boot 3 |
If `{authentication-method}` is equal to `kubernetes`:
| Property | Value |
| ----------------------------------------------- | ------------------- |
| `spring.cloud.vault.kubernetes.kubernetes-path` | `{kubernetes-path}` |
| `spring.cloud.vault.kubernetes.role` | `{role}` |
| Property | Value |
|-----------------------------------------------------------------------|---------------------------------------------------------|
| `spring.cloud.vault.kubernetes.role` | `{role}` |
| `spring.cloud.vault.kubernetes.kubernetes-path` | `{kubernetes-path}` |
| `spring.cloud.vault.kubernetes.kubernetes-service-account-token-file` | `{kubernetes-service-account-token-file}` Spring Boot 3 |
If `{authentication-method}` is equal to `token`:
| Property | Value |
| -------------------------- | --------- |
| `spring.cloud.vault.token` | `{token}` |

188
pom.xml
View File

@@ -5,13 +5,23 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bindings</artifactId>
<version>1.13.0-SNAPSHOT</version>
<artifactId>spring-cloud-bindings-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Cloud Native Buildpacks Bindings</name>
<name>Spring Cloud Cloud Native Buildpacks Bindings Parent</name>
<description>Java Library and Auto-configuration for Cloud Native Buildpack Bindings</description>
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>3.1.0</spring-boot.version>
</properties>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
@@ -19,173 +29,19 @@
</license>
</licenses>
<modules>
<module>spring-cloud-bindings</module>
<module>spring-cloud-bindings-tests</module>
</modules>
<scm>
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
</scm>
<developers>
<developer>
<id>scb-team</id>
<name>Spring Cloud Bindings Team</name>
<organizationUrl>https://github.com/spring-cloud/spring-cloud-bindings/graphs/contributors</organizationUrl>
</developer>
<developer>
<id>scb-team</id>
<name>Spring Cloud Bindings Team</name>
<organizationUrl>https://github.com/spring-cloud/spring-cloud-bindings/graphs/contributors</organizationUrl>
</developer>
</developers>
<properties>
<java.version>1.8</java.version>
<jsr305.version>3.0.2</jsr305.version>
<mariadb-r2dbc.version>1.0.3</mariadb-r2dbc.version>
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
<!-- Plugins -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${jsr305.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>${mariadb-r2dbc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-options</arg>
<arg>-Xlint:-processing</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<quiet>true</quiet>
<source>1.8</source>
<tags>
<tag>
<name>NonNullApi</name>
<placement>X</placement>
</tag>
</tags>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<runOrder>random</runOrder>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,16 @@
# Spring Cloud Bindings Test Boot 3
## Purpose of this module
For several Spring Cloud Bindings integrations, the properties bindings need to be different between Spring Boot 2 and Spring Boot 3.
In a Spring Boot 3 application, the mapping needs to be different because of changes with Spring Data Redis:
| Property | Value |
|--------------------------|----------|
| `spring.data.redis.port` | `{port}` |
| `spring.data.redis.host` | `{host}` |
This module runs an application, based on Spring Boot 3, and checks whether the `RedisConnectionFactory` properly picked up the `spring.data.redis.port` and `spring.data.redis.host` values.
Pay attention to the 2 environment variables set in the `pom.xml` that set `SERVICE_BINDING_ROOT` - they allow Spring Boot Bindings to load the proper configuration in `bindings/redis`

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bindings-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>spring-cloud-bindings-tests</artifactId>
<description>Test project to verify Spring Cloud Bindings works properly with Spring Boot 2</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bindings</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.kstyrc</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<environmentVariables>
<SERVICE_BINDING_ROOT>${basedir}/src/test/resources/bindings</SERVICE_BINDING_ROOT>
</environmentVariables>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,21 @@
package org.springframework.cloud;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(classes = RedisServerTestConfiguration.class)
public class IntegrationTest {
@Autowired
private RedisTemplate redisTemplate;
@Test
public void shouldSaveUser_toRedis() {
redisTemplate.opsForValue().set("hello", "world");
assertTrue(redisTemplate.hasKey("hello"));
}
}

View File

@@ -0,0 +1,33 @@
package org.springframework.cloud;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.core.io.ClassPathResource;
import redis.embedded.RedisServer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.IOException;
import java.util.Scanner;
@TestConfiguration
public class RedisServerTestConfiguration {
private final RedisServer redisServer;
public RedisServerTestConfiguration() throws IOException {
try (Scanner scanner = new Scanner(new ClassPathResource("bindings/redis/port").getInputStream())) {
int port = scanner.nextInt();
this.redisServer = new RedisServer(port);
}
}
@PostConstruct
public void postConstruct() {
redisServer.start();
}
@PreDestroy
public void preDestroy() {
redisServer.stop();
}
}

View File

@@ -0,0 +1,7 @@
package org.springframework.cloud;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBoot3Application {
}

View File

@@ -0,0 +1 @@
localhost

View File

@@ -0,0 +1 @@
4343

View File

@@ -0,0 +1 @@
redis

View File

@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bindings-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>spring-cloud-bindings</artifactId>
<name>Spring Cloud Cloud Native Buildpacks Bindings</name>
<description>Java Library and Auto-configuration for Cloud Native Buildpack Bindings</description>
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<scm>
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
</scm>
<developers>
<developer>
<id>scb-team</id>
<name>Spring Cloud Bindings Team</name>
<organizationUrl>https://github.com/spring-cloud/spring-cloud-bindings/graphs/contributors</organizationUrl>
</developer>
</developers>
<properties>
<jsr305.version>3.0.2</jsr305.version>
<mariadb-r2dbc.version>1.1.2</mariadb-r2dbc.version>
<!-- Plugins -->
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${jsr305.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>${mariadb-r2dbc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-options</arg>
<arg>-Xlint:-processing</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<quiet>true</quiet>
<source>1.8</source>
<tags>
<tag>
<name>NonNullApi</name>
<placement>X</placement>
</tag>
</tags>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<runOrder>random</runOrder>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -42,11 +42,19 @@ public final class ArtemisBindingsPropertiesProcessor implements BindingsPropert
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("broker-url").to("spring.artemis.broker-url");
map.from("pool.block-if-full").to("spring.artemis.pool.block-if-full");
map.from("pool.block-if-full-timeout").to("spring.artemis.pool.block-if-full-timeout");
map.from("pool.enabled").to("spring.artemis.pool.enabled");
map.from("pool.idle-timeout").to("spring.artemis.pool.idle-timeout");
map.from("pool.max-connections").to("spring.artemis.pool.max-connections");
map.from("pool.max-sessions-per-connection").to("spring.artemis.pool.max-sessions-per-connection");
map.from("pool.time-between-expiration-check").to("spring.artemis.pool.time-between-expiration-check");
map.from("pool.use-anonymous-producers").to("spring.artemis.pool.use-anonymous-producers");
map.from("host").to("spring.artemis.host");
map.from("mode").to("spring.artemis.mode");
map.from("password").to("spring.artemis.password");
map.from("port").to("spring.artemis.port");
map.from("user").to("spring.artemis.user");
map.from("embedded.cluster-password").to("spring.artemis.embedded.cluster-password");
@@ -56,16 +64,6 @@ public final class ArtemisBindingsPropertiesProcessor implements BindingsPropert
map.from("embedded.queues").to("spring.artemis.embedded.queues");
map.from("embedded.server-id").to("spring.artemis.embedded.server-id");
map.from("embedded.topics").to("spring.artemis.embedded.topics");
map.from("pool.block-if-full").to("spring.rabbitmq.pool.block-if-full");
map.from("pool.block-if-full-timeout").to("spring.rabbitmq.pool.block-if-full-timeout");
map.from("pool.enabled").to("spring.rabbitmq.pool.enabled");
map.from("pool.idle-timeout").to("spring.rabbitmq.pool.idle-timeout");
map.from("pool.max-connections").to("spring.rabbitmq.pool.max-connections");
map.from("pool.max-sessions-per-connection").to("spring.rabbitmq.pool.max-sessions-per-connection");
map.from("pool.time-between-expiration-check").to("spring.rabbitmq.pool.time-between-expiration-check");
map.from("pool.use-anonymous-producers").to("spring.rabbitmq.pool.use-anonymous-producers");
});
}
}

View File

@@ -16,8 +16,11 @@
package org.springframework.cloud.bindings.boot;
import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLog;
@@ -26,9 +29,6 @@ import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import java.util.HashMap;
import java.util.Map;
import static org.springframework.cloud.bindings.boot.PropertySourceContributor.contributePropertySource;
/**
@@ -59,7 +59,7 @@ public final class BindingFlattenedEnvironmentPostProcessor implements Applicati
@Override
public int getOrder() {
// Before ConfigFileApplicationListener so values there can use values from {@link Bindings}.
return ConfigFileApplicationListener.DEFAULT_ORDER - 1;
return ConfigDataEnvironmentPostProcessor.ORDER - 1;
}
@Override

View File

@@ -16,8 +16,13 @@
package org.springframework.cloud.bindings.boot;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLog;
@@ -28,10 +33,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.SpringFactoriesLoader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.springframework.cloud.bindings.boot.Guards.isGlobalEnabled;
import static org.springframework.cloud.bindings.boot.PropertySourceContributor.contributePropertySource;
@@ -77,7 +78,7 @@ public final class BindingSpecificEnvironmentPostProcessor implements Applicatio
@Override
public int getOrder() {
// Before ConfigFileApplicationListener so values there can use values from {@link Bindings}.
return ConfigFileApplicationListener.DEFAULT_ORDER - 1;
return ConfigDataEnvironmentPostProcessor.ORDER - 1;
}
@Override

View File

@@ -27,13 +27,11 @@ import static org.springframework.cloud.bindings.boot.Guards.isTypeEnabled;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of type: {@value TYPE}.
*/
final class ElasticsearchBindingsPropertiesProcessor implements BindingsPropertiesProcessor {
public final class CassandraBindingsPropertiesProcessor implements BindingsPropertiesProcessor {
/**
* The {@link Binding} type that this processor is interested in: {@value}.
**/
public static final String TYPE = "elasticsearch";
public static final String TYPE = "cassandra";
@Override
public void process(Environment environment, Bindings bindings, Map<String, Object> properties) {
@@ -43,19 +41,19 @@ final class ElasticsearchBindingsPropertiesProcessor implements BindingsProperti
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("cluster-name").to("spring.cassandra.cluster-name");
map.from("compression").to("spring.cassandra.compression");
map.from("contact-points").to("spring.cassandra.contact-points");
map.from("keyspace-name").to("spring.cassandra.keyspace-name");
map.from("password").to("spring.cassandra.password");
map.from("port").to("spring.cassandra.port");
map.from("ssl").to("spring.cassandra.ssl");
map.from("username").to("spring.cassandra.username");
map.from("endpoints").to("spring.data.elasticsearch.client.reactive.endpoints");
map.from("password").to("spring.data.elasticsearch.client.reactive.password");
map.from("use-ssl").to("spring.data.elasticsearch.client.reactive.use-ssl");
map.from("username").to("spring.data.elasticsearch.client.reactive.username");
map.from("password").to("spring.elasticsearch.jest.password");
map.from("proxy.host").to("spring.elasticsearch.jest.proxy.host");
map.from("proxy.port").to("spring.elasticsearch.jest.proxy.port");
map.from("username").to("spring.elasticsearch.jest.username");
map.from("password").to("spring.elasticsearch.rest.password");
map.from("uris").to("spring.elasticsearch.rest.uris");
map.from("username").to("spring.elasticsearch.rest.username");
map.from("request.throttler.drain-interval").to("spring.cassandra.request.throttler.drain-interval");
map.from("request.throttler.max-concurrent-requests").to("spring.cassandra.request.throttler.max-concurrent-requests");
map.from("request.throttler.max-queue-size").to("spring.cassandra.request.throttler.max-queue-size");
map.from("request.throttler.max-requests-per-second").to("spring.cassandra.request.throttler.max-requests-per-second");
});
}
}

View File

@@ -28,7 +28,6 @@ import static org.springframework.cloud.bindings.boot.Guards.isTypeEnabled;
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of type: {@value TYPE}.
*/
final class CouchbaseBindingsPropertiesProcessor implements BindingsPropertiesProcessor {
/**
* The {@link Binding} type that this processor is interested in: {@value}.
**/
@@ -42,15 +41,11 @@ final class CouchbaseBindingsPropertiesProcessor implements BindingsPropertiesPr
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("bootstrap-hosts").to("spring.couchbase.bootstrap-hosts");
map.from("bucket.name").to("spring.couchbase.bucket.name");
map.from("bucket.password").to("spring.couchbase.bucket.password");
map.from("env.bootstrap.http-direct-port").to("spring.couchbase.env.bootstrap.http-direct-port");
map.from("env.bootstrap.http-ssl-port").to("spring.couchbase.env.bootstrap.http-ssl-port");
map.from("bucket-name").to("spring.data.couchbase.bucket-name");
map.from("connection-string").to("spring.couchbase.connection-string");
map.from("password").to("spring.couchbase.password");
map.from("username").to("spring.couchbase.username");
});
}
}

View File

@@ -27,12 +27,12 @@ import static org.springframework.cloud.bindings.boot.Guards.isTypeEnabled;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of type: {@value TYPE}.
*/
public final class CassandraBindingsPropertiesProcessor implements BindingsPropertiesProcessor {
final class ElasticsearchBindingsPropertiesProcessor implements BindingsPropertiesProcessor {
/**
* The {@link Binding} type that this processor is interested in: {@value}.
**/
public static final String TYPE = "cassandra";
public static final String TYPE = "elasticsearch";
@Override
public void process(Environment environment, Bindings bindings, Map<String, Object> properties) {
@@ -42,16 +42,9 @@ public final class CassandraBindingsPropertiesProcessor implements BindingsPrope
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("cluster-name").to("spring.data.cassandra.cluster-name");
map.from("compression").to("spring.data.cassandra.compression");
map.from("contact-points").to("spring.data.cassandra.contact-points");
map.from("keyspace-name").to("spring.data.cassandra.keyspace-name");
map.from("password").to("spring.data.cassandra.password");
map.from("port").to("spring.data.cassandra.port");
map.from("ssl").to("spring.data.cassandra.ssl");
map.from("username").to("spring.data.cassandra.username");
map.from("password").to("spring.elasticsearch.password");
map.from("uris").to("spring.elasticsearch.uris");
map.from("username").to("spring.elasticsearch.username");
});
}
}

View File

@@ -21,7 +21,7 @@ import org.springframework.core.env.Environment;
final class Guards {
static boolean isGlobalEnabled(Environment environment) {
return environment.getProperty("org.springframework.cloud.bindings.boot.enable", Boolean.class, false);
return environment.getProperty("org.springframework.cloud.bindings.boot.enable", Boolean.class, true);
}
static boolean isTypeEnabled(Environment environment, String type) {

View File

@@ -41,11 +41,11 @@ final class Neo4JBindingsPropertiesProcessor implements BindingsPropertiesProces
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("password").to("spring.neo4j.authentication.password");
map.from("uri").to("spring.neo4j.uri");
map.from("username").to("spring.neo4j.authentication.username");
map.from("password").to("spring.data.neo4j.password");
map.from("uri").to("spring.data.neo4j.uri");
map.from("username").to("spring.data.neo4j.username");
});
}
}

View File

@@ -69,8 +69,7 @@ public final class PostgreSqlBindingsPropertiesProcessor implements BindingsProp
(host, port, database) -> String.format("jdbc:postgresql://%s:%s/%s", host, port, database));
String sslParam = buildSslModeParam(binding);
String dbOptions = buildDbOptions(binding);
String sslModeOptions = dbOptions;
String sslModeOptions = buildDbOptions(binding);
if (!"".equals(sslParam) && !"".equals(sslModeOptions)) {
sslModeOptions = sslParam + "&" + sslModeOptions;
} else if (!"".equals(sslParam) ) {

View File

@@ -43,17 +43,17 @@ public final class RedisBindingsPropertiesProcessor implements BindingsPropertie
bindings.filterBindings(TYPE).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("client-name").to("spring.redis.client-name");
map.from("cluster.max-redirects").to("spring.redis.cluster.max-redirects");
map.from("cluster.nodes").to("spring.redis.cluster.nodes");
map.from("database").to("spring.redis.database");
map.from("host").to("spring.redis.host");
map.from("password").to("spring.redis.password");
map.from("port").to("spring.redis.port");
map.from("sentinel.master").to("spring.redis.sentinel.master");
map.from("sentinel.nodes").to("spring.redis.sentinel.nodes");
map.from("ssl").to("spring.redis.ssl");
map.from("url").to("spring.redis.url");
map.from("client-name").to("spring.data.redis.client-name");
map.from("cluster.max-redirects").to("spring.data.redis.cluster.max-redirects");
map.from("cluster.nodes").to("spring.data.redis.cluster.nodes");
map.from("database").to("spring.data.redis.database");
map.from("host").to("spring.data.redis.host");
map.from("password").to("spring.data.redis.password");
map.from("port").to("spring.data.redis.port");
map.from("sentinel.master").to("spring.data.redis.sentinel.master");
map.from("sentinel.nodes").to("spring.data.redis.sentinel.nodes");
map.from("ssl").to("spring.data.redis.ssl");
map.from("url").to("spring.data.redis.url");
});
}

View File

@@ -31,7 +31,6 @@ import static org.springframework.cloud.bindings.boot.Guards.isTypeEnabled;
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of type: {@value TYPE}.
*/
public final class VaultBindingsPropertiesProcessor implements BindingsPropertiesProcessor, ApplicationListener<ApplicationPreparedEvent> {
/**
* The {@link Binding} type that this processor is interested in: {@value}.
**/
@@ -73,25 +72,30 @@ public final class VaultBindingsPropertiesProcessor implements BindingsPropertie
map.from("aws-ec2-instance-identity-document").to("spring.cloud.vault.aws-ec2.identity-document");
map.from("nonce").to("spring.cloud.vault.aws-ec2.nonce");
break;
case "GCP_GCE":
map.from("role").to("spring.cloud.vault.gcp-gce.role");
map.from("gcp-path").to("spring.cloud.vault.gcp-gce.gcp-path");
map.from("gcp-service-account").to("spring.cloud.vault.gcp-gce.service-account");
break;
case "AWS_IAM":
map.from("role").to("spring.cloud.vault.aws-iam.role");
map.from("aws-path").to("spring.cloud.vault.aws-iam.aws-path");
map.from("aws-iam-server-id").to("spring.cloud.vault.aws-iam.server-id");
map.from("aws-sts-endpoint-uri").to("spring.cloud.vault.aws-iam.endpoint-uri");
map.from("aws-iam-server-name").to("spring.cloud.vault.aws-iam.server-name");
break;
case "AZURE_MSI":
map.from("role").to("spring.cloud.vault.azure-msi.role");
map.from("azure-path").to("spring.cloud.vault.azure-msi.azure-path");
map.from("metadata-service").to("spring.cloud.vault.azure-msi.metadata-service");
map.from("identity-token-service").to("spring.cloud.vault.azure-msi.identity-token-service");
break;
case "CERT":
properties.put("spring.cloud.vault.ssl.key-store", binding.getSecretFilePath("keystore.jks").toString());
map.from("key-store-password").to("spring.cloud.vault.ssl.key-store-password");
map.from("cert-auth-path").to("spring.cloud.vault.ssl.cert-auth-path");
break;
case "GCP_GCE":
map.from("role").to("spring.cloud.vault.gcp-gce.role");
map.from("gcp-path").to("spring.cloud.vault.gcp-gce.gcp-path");
map.from("gcp-service-account").to("spring.cloud.vault.gcp-gce.service-account");
properties.put("spring.cloud.vault.ssl.trust-store", binding.getSecretFilePath("truststore.jks").toString());
map.from("trust-store").to("spring.cloud.vault.ssl.trust-store");
map.from("trust-store-password").to("spring.cloud.vault.ssl.trust-store-password");
break;
case "GCP_IAM":
if (binding.getSecret().containsKey("credentials.json")) {
@@ -102,11 +106,12 @@ public final class VaultBindingsPropertiesProcessor implements BindingsPropertie
map.from("gcp-path").to("spring.cloud.vault.gcp-iam.gcp-path");
map.from("jwt-validity").to("spring.cloud.vault.gcp-iam.jwt-validity");
map.from("gcp-project-id").to("spring.cloud.vault.gcp-iam.project-id");
map.from("gcp-service-account").to("spring.cloud.vault.gcp-iam.service-account");
map.from("gcp-service-account").to("spring.cloud.vault.gcp-iam.service-account-id");
break;
case "KUBERNETES":
map.from("role").to("spring.cloud.vault.kubernetes.role");
map.from("kubernetes-path").to("spring.cloud.vault.kubernetes.kubernetes-path");
map.from("kubernetes-service-account-token-file").to("spring.cloud.vault.kubernetes.kubernetes-service-account-token-file");
break;
default:
LOG.warn(String.format("Binding '%s' contains unrecognized 'method'", binding.getName()));
@@ -118,4 +123,5 @@ public final class VaultBindingsPropertiesProcessor implements BindingsPropertie
public void onApplicationEvent(ApplicationPreparedEvent event) {
LOG.replayTo(getClass());
}
}

View File

@@ -32,13 +32,12 @@ import static org.springframework.cloud.bindings.boot.ArtemisBindingsPropertiesP
@DisplayName("ActiveMQ Artemis BindingsPropertiesProcessor")
final class ArtemisBindingsPropertiesProcessorTest {
private final Bindings bindings = new Bindings(
private final Bindings bindingsSpringBoot3 = new Bindings(
new Binding("test-name", Paths.get("test-path"),
new FluentMap()
.withEntry(Binding.TYPE, TYPE)
.withEntry("mode", "EMBEDDED")
.withEntry("host", "test-host")
.withEntry("port", "test-port")
.withEntry("broker-url", "tcp://test-host:test-port")
.withEntry("user", "test-user")
.withEntry("password", "test-password")
)
@@ -50,13 +49,12 @@ final class ArtemisBindingsPropertiesProcessorTest {
@Test
@DisplayName("contributes properties")
void test() {
new ArtemisBindingsPropertiesProcessor().process(environment, bindings, properties);
void testSb3() {
new ArtemisBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties)
.containsEntry("spring.artemis.mode", "EMBEDDED")
.containsEntry("spring.artemis.host", "test-host")
.containsEntry("spring.artemis.broker-url", "tcp://test-host:test-port")
.containsEntry("spring.artemis.password", "test-password")
.containsEntry("spring.artemis.port", "test-port")
.containsEntry("spring.artemis.user", "test-user");
}
@@ -65,8 +63,7 @@ final class ArtemisBindingsPropertiesProcessorTest {
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.artemis.enable", "false");
new ArtemisBindingsPropertiesProcessor().process(environment, bindings, properties);
new ArtemisBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
}

View File

@@ -16,17 +16,17 @@
package org.springframework.cloud.bindings.boot;
import java.nio.file.Paths;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
import org.springframework.mock.env.MockEnvironment;
import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Binding-flattened EnvironmentPostProcessor")
@@ -82,7 +82,7 @@ final class BindingFlattenedEnvironmentPostProcessorTest {
@DisplayName("has order before ConfigFileApplicationListener")
void order() {
assertThat(new BindingFlattenedEnvironmentPostProcessor(new Bindings()).getOrder())
.isLessThan(ConfigFileApplicationListener.DEFAULT_ORDER);
.isLessThan(ConfigDataEnvironmentPostProcessor.ORDER);
}
}

View File

@@ -19,7 +19,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -98,7 +98,7 @@ final class BindingSpecificEnvironmentPostProcessorTest {
@DisplayName("has order before ConfigFileApplicationListener")
void order() {
assertThat(new BindingSpecificEnvironmentPostProcessor(new Bindings()).getOrder())
.isLessThan(ConfigFileApplicationListener.DEFAULT_ORDER);
.isLessThan(ConfigDataEnvironmentPostProcessor.ORDER);
}
@Test

View File

@@ -44,6 +44,10 @@ final class CassandraBindingsPropertiesProcessorTest {
.withEntry("port", "test-port")
.withEntry("ssl", "test-ssl")
.withEntry("username", "test-username")
.withEntry("request.throttler.drain-interval", "test-drain-interval")
.withEntry("request.throttler.max-concurrent-requests", "test-max-concurrent-requests")
.withEntry("request.throttler.max-queue-size", "test-max-queue-size")
.withEntry("request.throttler.max-requests-per-second", "test-max-requests-per-second")
)
);
@@ -53,17 +57,21 @@ final class CassandraBindingsPropertiesProcessorTest {
@Test
@DisplayName("contributes properties")
void test() {
void testSb3() {
new CassandraBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.data.cassandra.cluster-name", "test-cluster-name")
.containsEntry("spring.data.cassandra.compression", "test-compression")
.containsEntry("spring.data.cassandra.contact-points", "test-contact-points")
.containsEntry("spring.data.cassandra.keyspace-name", "test-keyspace-name")
.containsEntry("spring.data.cassandra.password", "test-password")
.containsEntry("spring.data.cassandra.port", "test-port")
.containsEntry("spring.data.cassandra.ssl", "test-ssl")
.containsEntry("spring.data.cassandra.username", "test-username");
.containsEntry("spring.cassandra.cluster-name", "test-cluster-name")
.containsEntry("spring.cassandra.compression", "test-compression")
.containsEntry("spring.cassandra.contact-points", "test-contact-points")
.containsEntry("spring.cassandra.keyspace-name", "test-keyspace-name")
.containsEntry("spring.cassandra.password", "test-password")
.containsEntry("spring.cassandra.port", "test-port")
.containsEntry("spring.cassandra.ssl", "test-ssl")
.containsEntry("spring.cassandra.username", "test-username")
.containsEntry("spring.cassandra.request.throttler.drain-interval", "test-drain-interval")
.containsEntry("spring.cassandra.request.throttler.max-concurrent-requests", "test-max-concurrent-requests")
.containsEntry("spring.cassandra.request.throttler.max-queue-size", "test-max-queue-size")
.containsEntry("spring.cassandra.request.throttler.max-requests-per-second", "test-max-requests-per-second");
}
@Test
@@ -72,7 +80,6 @@ final class CassandraBindingsPropertiesProcessorTest {
environment.setProperty("org.springframework.cloud.bindings.boot.cassandra.enable", "false");
new CassandraBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
}

View File

@@ -32,17 +32,14 @@ import static org.springframework.cloud.bindings.boot.CouchbaseBindingsPropertie
@DisplayName("Couchbase BindingsPropertiesProcessor")
final class CouchbaseBindingsPropertiesProcessorTest {
private final Bindings bindings = new Bindings(
private final Bindings bindingsSpringBoot3 = new Bindings(
new Binding("test-name", Paths.get("test-path"),
new FluentMap()
.withEntry(Binding.TYPE, TYPE)
.withEntry("bootstrap-hosts", "test-bootstrap-hosts")
.withEntry("bucket.name", "test-bucket-name")
.withEntry("bucket.password", "test-bucket-password")
.withEntry("env.bootstrap.http-direct-port", "test-env-bootstrap-http-direct-port")
.withEntry("env.bootstrap.http-ssl-port", "test-env-bootstrap-http-ssl-port")
.withEntry("password", "test-password")
.withEntry("connection-string", "test-connection-string")
.withEntry("bucket-name", "test-bucket-name")
.withEntry("username", "test-username")
.withEntry("password", "test-password")
)
);
@@ -52,16 +49,13 @@ final class CouchbaseBindingsPropertiesProcessorTest {
@Test
@DisplayName("contributes properties")
void test() {
new CouchbaseBindingsPropertiesProcessor().process(environment, bindings, properties);
void testSb3() {
new CouchbaseBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties)
.containsEntry("spring.couchbase.bootstrap-hosts", "test-bootstrap-hosts")
.containsEntry("spring.couchbase.bucket.name", "test-bucket-name")
.containsEntry("spring.couchbase.bucket.password", "test-bucket-password")
.containsEntry("spring.couchbase.env.bootstrap.http-direct-port", "test-env-bootstrap-http-direct-port")
.containsEntry("spring.couchbase.env.bootstrap.http-ssl-port", "test-env-bootstrap-http-ssl-port")
.containsEntry("spring.couchbase.password", "test-password")
.containsEntry("spring.couchbase.username", "test-username");
.containsEntry("spring.couchbase.connection-string", "test-connection-string")
.containsEntry("spring.data.couchbase.bucket-name", "test-bucket-name")
.containsEntry("spring.couchbase.username", "test-username")
.containsEntry("spring.couchbase.password", "test-password");
}
@Test
@@ -69,8 +63,7 @@ final class CouchbaseBindingsPropertiesProcessorTest {
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.couchbase.enable", "false");
new CouchbaseBindingsPropertiesProcessor().process(environment, bindings, properties);
new CouchbaseBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
}

View File

@@ -32,40 +32,29 @@ import static org.springframework.cloud.bindings.boot.ElasticsearchBindingsPrope
@DisplayName("Elasticsearch BindingsPropertiesProcessor")
final class ElasticsearchBindingsPropertiesProcessorTest {
private final Bindings bindings = new Bindings(
private final Bindings bindingsSpringBoot3 = new Bindings(
new Binding("test-name", Paths.get("test-path"),
new FluentMap()
.withEntry(Binding.TYPE, TYPE)
.withEntry("endpoints", "test-endpoints")
.withEntry("password", "test-password")
.withEntry("use-ssl", "test-use-ssl")
.withEntry("username", "test-username")
.withEntry("proxy.host", "test-proxy-host")
.withEntry("proxy.port", "test-proxy-port")
.withEntry("uris", "test-uris")
.withEntry("username", "test-username")
)
);
private final MockEnvironment environment = new MockEnvironment();
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
new ElasticsearchBindingsPropertiesProcessor().process(environment, bindings, properties);
@DisplayName("contributes properties - Spring Boot 2 flavor")
void testSb3() {
new ElasticsearchBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties)
.containsEntry("spring.data.elasticsearch.client.reactive.endpoints", "test-endpoints")
.containsEntry("spring.data.elasticsearch.client.reactive.password", "test-password")
.containsEntry("spring.data.elasticsearch.client.reactive.use-ssl", "test-use-ssl")
.containsEntry("spring.data.elasticsearch.client.reactive.username", "test-username")
.containsEntry("spring.elasticsearch.jest.password", "test-password")
.containsEntry("spring.elasticsearch.jest.proxy.host", "test-proxy-host")
.containsEntry("spring.elasticsearch.jest.proxy.port", "test-proxy-port")
.containsEntry("spring.elasticsearch.jest.username", "test-username")
.containsEntry("spring.elasticsearch.rest.password", "test-password")
.containsEntry("spring.elasticsearch.rest.uris", "test-uris")
.containsEntry("spring.elasticsearch.rest.username", "test-username");
.containsEntry("spring.elasticsearch.password", "test-password")
.containsEntry("spring.elasticsearch.uris", "test-uris")
.containsEntry("spring.elasticsearch.username", "test-username");
}
@Test
@@ -73,8 +62,7 @@ final class ElasticsearchBindingsPropertiesProcessorTest {
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.elasticsearch.enable", "false");
new ElasticsearchBindingsPropertiesProcessor().process(environment, bindings, properties);
new ElasticsearchBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
}

View File

@@ -35,9 +35,9 @@ final class GuardsTest {
private final MockEnvironment environment = new MockEnvironment();
@Test
@DisplayName("returns false if unset")
@DisplayName("returns true if unset")
void unset() {
assertThat(isGlobalEnabled(environment)).isFalse();
assertThat(isGlobalEnabled(environment)).isTrue();
}
@Test

View File

@@ -48,12 +48,12 @@ final class Neo4JBindingsPropertiesProcessorTest {
@Test
@DisplayName("contributes properties")
void test() {
void testSb3() {
new Neo4JBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.data.neo4j.password", "test-password")
.containsEntry("spring.data.neo4j.uri", "test-uri")
.containsEntry("spring.data.neo4j.username", "test-username");
.containsEntry("spring.neo4j.authentication.password", "test-password")
.containsEntry("spring.neo4j.uri", "test-uri")
.containsEntry("spring.neo4j.authentication.username", "test-username");
}
@Test
@@ -62,8 +62,8 @@ final class Neo4JBindingsPropertiesProcessorTest {
environment.setProperty("org.springframework.cloud.bindings.boot.neo4j.enable", "false");
new Neo4JBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
}
}

View File

@@ -56,20 +56,21 @@ final class RedisBindingsPropertiesProcessorTest {
@Test
@DisplayName("contributes properties")
void test() {
void testSb3() {
new RedisBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.redis.client-name", "test-client-name")
.containsEntry("spring.redis.cluster.max-redirects", "test-cluster-max-redirects")
.containsEntry("spring.redis.cluster.nodes", "test-cluster-nodes")
.containsEntry("spring.redis.database", "test-database")
.containsEntry("spring.redis.host", "test-host")
.containsEntry("spring.redis.password", "test-password")
.containsEntry("spring.redis.port", "test-port")
.containsEntry("spring.redis.sentinel.master", "test-sentinel-master")
.containsEntry("spring.redis.sentinel.nodes", "test-sentinel-nodes")
.containsEntry("spring.redis.ssl", "test-ssl")
.containsEntry("spring.redis.url", "test-url");
.containsEntry("spring.data.redis.client-name", "test-client-name")
.containsEntry("spring.data.redis.cluster.max-redirects", "test-cluster-max-redirects")
.containsEntry("spring.data.redis.cluster.nodes", "test-cluster-nodes")
.containsEntry("spring.data.redis.database", "test-database")
.containsEntry("spring.data.redis.host", "test-host")
.containsEntry("spring.data.redis.password", "test-password")
.containsEntry("spring.data.redis.port", "test-port")
.containsEntry("spring.data.redis.sentinel.master", "test-sentinel-master")
.containsEntry("spring.data.redis.sentinel.nodes", "test-sentinel-nodes")
.containsEntry("spring.data.redis.ssl", "test-ssl")
.containsEntry("spring.data.redis.url", "test-url");
}
@Test
@@ -78,7 +79,6 @@ final class RedisBindingsPropertiesProcessorTest {
environment.setProperty("org.springframework.cloud.bindings.boot.redis.enable", "false");
new RedisBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
}

View File

@@ -47,12 +47,6 @@ final class VaultBindingsPropertiesProcessorTest {
)
);
new VaultBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.cloud.vault.uri", "test-uri")
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "token")
.containsEntry("spring.cloud.vault.token", "test-token");
}
@Test
@@ -108,6 +102,8 @@ final class VaultBindingsPropertiesProcessorTest {
.withEntry("authentication-method", "cert")
.withEntry("cert-auth-path", "test-cert-auth-path")
.withEntry("key-store-password", "test-key-store-password")
.withEntry("truststore.jks", "trust store contents!")
.withEntry("trust-store-password", "test-trust-store-password")
.withEntry("keystore.jks", "key store contents!")
)
);
@@ -117,9 +113,11 @@ final class VaultBindingsPropertiesProcessorTest {
.containsEntry("spring.cloud.vault.uri", "test-uri")
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "cert")
.containsEntry("spring.cloud.vault.ssl.cert-auth-path", "test-cert-auth-path")
.containsEntry("spring.cloud.vault.ssl.key-store", "test-path/keystore.jks")
.containsEntry("spring.cloud.vault.ssl.key-store-password", "test-key-store-password")
.containsEntry("spring.cloud.vault.ssl.cert-auth-path", "test-cert-auth-path");
.containsEntry("spring.cloud.vault.ssl.trust-store", "test-path/truststore.jks")
.containsEntry("spring.cloud.vault.ssl.trust-store-password", "test-trust-store-password");
}
@Test
@@ -136,15 +134,6 @@ final class VaultBindingsPropertiesProcessorTest {
)
);
new VaultBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.cloud.vault.uri", "test-uri")
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "aws_ec2")
.containsEntry("spring.cloud.vault.aws-ec2.role", "test-role")
.containsEntry("spring.cloud.vault.aws-ec2.aws-ec2-path", "test-aws-ec2-path")
.containsEntry("spring.cloud.vault.aws-ec2.identity-document", "test-identity-document")
.containsEntry("spring.cloud.vault.aws-ec2.nonce", "test-nonce");
}
@Test
@@ -155,6 +144,7 @@ final class VaultBindingsPropertiesProcessorTest {
baseSecret()
.withEntry("authentication-method", "aws_iam")
.withEntry("aws-iam-server-id", "test-server-id")
.withEntry("aws-iam-server-name", "test-server-name")
.withEntry("aws-path", "test-aws-path")
.withEntry("aws-sts-endpoint-uri", "test-endpoint-uri")
.withEntry("role", "test-role")
@@ -168,7 +158,7 @@ final class VaultBindingsPropertiesProcessorTest {
.containsEntry("spring.cloud.vault.authentication", "aws_iam")
.containsEntry("spring.cloud.vault.aws-iam.role", "test-role")
.containsEntry("spring.cloud.vault.aws-iam.aws-path", "test-aws-path")
.containsEntry("spring.cloud.vault.aws-iam.server-id", "test-server-id")
.containsEntry("spring.cloud.vault.aws-iam.server-name", "test-server-name")
.containsEntry("spring.cloud.vault.aws-iam.endpoint-uri", "test-endpoint-uri");
}
@@ -181,6 +171,8 @@ final class VaultBindingsPropertiesProcessorTest {
.withEntry("authentication-method", "azure_msi")
.withEntry("azure-path", "test-azure-path")
.withEntry("role", "test-role")
.withEntry("metadata-service", "test-metadata-service")
.withEntry("identity-token-service", "test-identity-token-service")
)
);
@@ -190,7 +182,9 @@ final class VaultBindingsPropertiesProcessorTest {
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "azure_msi")
.containsEntry("spring.cloud.vault.azure-msi.role", "test-role")
.containsEntry("spring.cloud.vault.azure-msi.azure-path", "test-azure-path");
.containsEntry("spring.cloud.vault.azure-msi.azure-path", "test-azure-path")
.containsEntry("spring.cloud.vault.azure-msi.metadata-service", "test-metadata-service")
.containsEntry("spring.cloud.vault.azure-msi.identity-token-service", "test-identity-token-service");
}
@Test
@@ -206,14 +200,6 @@ final class VaultBindingsPropertiesProcessorTest {
)
);
new VaultBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.cloud.vault.uri", "test-uri")
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "gcp_gce")
.containsEntry("spring.cloud.vault.gcp-gce.role", "test-role")
.containsEntry("spring.cloud.vault.gcp-gce.gcp-path", "test-gcp-path")
.containsEntry("spring.cloud.vault.gcp-gce.service-account", "test-service-account");
}
@Test
@@ -244,7 +230,7 @@ final class VaultBindingsPropertiesProcessorTest {
.containsEntry("spring.cloud.vault.gcp-iam.gcp-path", "test-gcp-path")
.containsEntry("spring.cloud.vault.gcp-iam.jwt-validity", "test-jwt-validity")
.containsEntry("spring.cloud.vault.gcp-iam.project-id", "test-project-id")
.containsEntry("spring.cloud.vault.gcp-iam.service-account", "test-service-account");
.containsEntry("spring.cloud.vault.gcp-iam.service-account-id", "test-service-account");
}
@Test
@@ -256,6 +242,7 @@ final class VaultBindingsPropertiesProcessorTest {
.withEntry("authentication-method", "kubernetes")
.withEntry("role", "test-role")
.withEntry("kubernetes-path", "test-kubernetes-path")
.withEntry("kubernetes-service-account-token-file", "test-kubernetes-service-account-token-file")
)
);
@@ -265,7 +252,8 @@ final class VaultBindingsPropertiesProcessorTest {
.containsEntry("spring.cloud.vault.namespace", "test-namespace")
.containsEntry("spring.cloud.vault.authentication", "kubernetes")
.containsEntry("spring.cloud.vault.kubernetes.role", "test-role")
.containsEntry("spring.cloud.vault.kubernetes.kubernetes-path", "test-kubernetes-path");
.containsEntry("spring.cloud.vault.kubernetes.kubernetes-path", "test-kubernetes-path")
.containsEntry("spring.cloud.vault.kubernetes.kubernetes-service-account-token-file", "test-kubernetes-service-account-token-file");
}
@Test

Some files were not shown because too many files have changed in this diff Show More