-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4029c1e
commit 55c257c
Showing
28 changed files
with
3,294 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "maven" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: "gradle" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Gradle Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Maven Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
|
||
- name: Build with Maven | ||
run: ./mvnw verify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
java=17.0.8-tem | ||
gradle=8.4 | ||
maven=3.9.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# tc-guide-securing-spring-boot-microservice-using-keycloak-and-testcontainers | ||
Guide for Securing Spring Boot Microservice using Keycloak and Testcontainers | ||
# Securing Spring Boot Microservice using Keycloak and Testcontainers | ||
|
||
This is sample code for [Securing Spring Boot Microservice using Keycloak and Testcontainers](https://testcontainers.com/guides/securing-spring-boot-microservice-using-keycloak-and-testcontainers) guide. | ||
|
||
## 1. Setup Environment | ||
Make sure you have Java 8+ and a [compatible Docker environment](https://www.testcontainers.org/supported_docker_environment/) installed. | ||
If you are going to use Maven build tool then make sure Java 17+ is installed. | ||
|
||
For example: | ||
|
||
```shell | ||
$ java -version | ||
openjdk version "17.0.4" 2022-07-19 | ||
OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8) | ||
OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode, sharing) | ||
$ docker version | ||
... | ||
Server: Docker Desktop 4.12.0 (85629) | ||
Engine: | ||
Version: 20.10.17 | ||
API version: 1.41 (minimum version 1.12) | ||
Go version: go1.17.11 | ||
... | ||
``` | ||
|
||
## 2. Setup Project | ||
|
||
* Clone the repository | ||
|
||
```shell | ||
git clone https://github.com/testcontainers/tc-guide-securing-spring-boot-microservice-using-keycloak-and-testcontainers.git | ||
cd tc-guide-securing-spring-boot-microservice-using-keycloak-and-testcontainers | ||
``` | ||
|
||
* Open the **tc-guide-securing-spring-boot-microservice-using-keycloak-and-testcontainers** project in your favorite IDE. | ||
|
||
## 3. Run Tests | ||
|
||
Run the command to run the tests. | ||
|
||
```shell | ||
$ ./gradlew test //for Gradle | ||
$ ./mvnw verify //for Maven | ||
``` | ||
|
||
The tests should pass. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.2.0' | ||
id 'io.spring.dependency-management' version '1.1.4' | ||
id 'com.diffplug.spotless' version "6.18.0" | ||
} | ||
|
||
group = 'com.testcontainers' | ||
version = '1.0.0-SNAPSHOT' | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
vendor = JvmVendorSpec.ADOPTIUM | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' | ||
|
||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.springframework.security:spring-security-test' | ||
testImplementation 'org.springframework.boot:spring-boot-testcontainers' | ||
testImplementation 'org.testcontainers:junit-jupiter' | ||
testImplementation 'com.github.dasniko:testcontainers-keycloak:3.2.0' | ||
testImplementation 'io.rest-assured:rest-assured' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
testLogging { | ||
events = ["PASSED", "FAILED", "SKIPPED"] | ||
showStandardStreams = true | ||
exceptionFormat = "full" | ||
} | ||
} | ||
|
||
spotless { | ||
java { | ||
importOrder() | ||
removeUnusedImports() | ||
palantirJavaFormat("2.30.0") | ||
formatAnnotations() | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.