Skip to content

Commit

Permalink
dependencies-upgrade (#453)
Browse files Browse the repository at this point in the history
* dependencies-upgrade
  • Loading branch information
mkrzywanski authored Aug 11, 2024
1 parent 097bfaa commit bbf3920
Show file tree
Hide file tree
Showing 56 changed files with 415 additions and 434 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/promotion-norifier-backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ jobs:
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '21'
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
Expand Down
45 changes: 24 additions & 21 deletions promotion-notifier-backend/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
buildscript {
ext {
keycloakVersion = '18.0.0'
lombokVersion = '1.18.28'
springVersion = '6.0.11'
groovyVersion = '4.0.0'
springBootVersion = '3.1.3'
springDepenedcyMgmtVersion = '1.1.3'
springCloudVersion = '4.0.4'
testcontainersVersion = '1.19.0'
keycloakVersion = '25.0.1'
keycloakTestcontainersVersion = '3.4.0'
lombokVersion = '1.18.34'
groovyVersion = '4.0.22'
springBootVersion = '3.3.2'
springDepenedcyMgmtVersion = '1.1.6'
springCloudVersion = '2023.0.2'
testcontainersVersion = '1.19.8'
awaitilityVersion = '4.2.0'
wiremockVersion = '3.0.1'
baseDockerImage = 'openjdk:17.0.1-slim'
wiremockVersion = '2.35.2'
baseDockerImage = 'azul/zulu-openjdk:21-latest'
hamcrestVersion = '2.2'
seleniumVersion = '4.12.1'
getStubsJarFromProject = this.&getStubsJarFromProject
}
}

plugins {
id 'org.springframework.boot' version "${springBootVersion}" apply false
id 'io.spring.dependency-management' version "${springDepenedcyMgmtVersion}" apply false
id 'org.springframework.cloud.contract' version "${springCloudVersion}" apply false
id 'com.google.cloud.tools.jib' version '3.3.1' apply false
id 'org.springframework.cloud.contract' version "4.1.3" apply false
id 'com.google.cloud.tools.jib' version '3.4.3' apply false
id "io.freefair.lombok" version "8.3"
}

Expand All @@ -31,12 +32,16 @@ allprojects {

group = 'io.mkrzywanski'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
sourceCompatibility = JavaVersion.VERSION_21

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
}
}

subprojects {
Expand All @@ -45,7 +50,6 @@ subprojects {
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'


test {
useJUnitPlatform()
testLogging {
Expand All @@ -64,16 +68,14 @@ subprojects {
}

dependencies {
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.0'
implementation "org.apache.groovy:groovy:${groovyVersion}"

testImplementation platform("org.spockframework:spock-bom:2.3-groovy-4.0")
testImplementation "org.spockframework:spock-core"
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.1'

testImplementation 'org.exparity:hamcrest-date:2.0.8'
testImplementation "org.hamcrest:hamcrest-core:${hamcrestVersion}"
testImplementation 'org.assertj:assertj-core:3.24.2'
testRuntimeOnly "net.bytebuddy:byte-buddy:1.14.7"
testImplementation 'org.assertj:assertj-core'

implementation "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
Expand All @@ -100,10 +102,10 @@ task codeCoverageReport(type: JacocoReport) {
}

reports {
xml.enabled true
xml.required = true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled false
csv.enabled false
html.required = false
csv.required = false
}
}

Expand All @@ -114,3 +116,4 @@ codeCoverageReport.dependsOn {
def getStubsJarFromProject(String projectName) {
project(projectName).getTasksByName('verifierStubsJar', false).first().outputs.files
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
org.gradle.caching=true
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ configurations {
dependencies {
testImplementation project(':pn-shared-test-modules:keycloak-test-container')
contractTestImplementation group: 'org.spockframework', name: 'spock-spring'
contractTestImplementation "org.springframework.cloud:spring-cloud-starter-contract-stub-runner:${springCloudVersion}"
contractTestImplementation "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
contractTestImplementation project(":keycloak-modules:keycloak-listeners")
contractTestImplementation project(":pn-shared-test-modules:common")
contractTestRuntimeClasspath getStubsJarFromProject(':pn-user-service')
contractTestRuntimeOnly getStubsJarFromProject(':pn-user-service')
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${springCloudVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.mkrzywanski.keycloak.listeners


import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerPort
Expand All @@ -27,7 +26,7 @@ class UserServiceClientContractSpec extends Specification {
def userId = "db3ca7f3-7c8b-48ab-8245-4126a1389daf"

when:
def result = userServiceClient.notifyUserCreated(UserCreatedEventData.create(getDetails(), userId))
def result = userServiceClient.notifyUserCreated(UserCreatedEvent.create(getDetails(), userId))

then:
result == Result.SUCCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile

plugins {
id 'java'
id 'com.bmuschko.docker-remote-api' version '9.3.2'
id "nebula.java-cross-compile" version "6.2.0"
id 'io.spring.dependency-management'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11
id 'groovy'
}

sourceSets {
Expand Down Expand Up @@ -44,24 +40,23 @@ dependencies {
implementation("org.keycloak:keycloak-server-spi:${keycloakVersion}")
implementation("org.keycloak:keycloak-server-spi-private:${keycloakVersion}")
implementation("org.keycloak:keycloak-services:${keycloakVersion}")
testImplementation 'com.squareup.okhttp3:okhttp:4.11.0'
testImplementation 'com.squareup.okhttp3:okhttp-urlconnection:4.11.0'

testImplementation project(':pn-shared-test-modules:keycloak-test-container')
testImplementation "org.testcontainers:selenium:1.19.0"
testImplementation 'org.seleniumhq.selenium:selenium-java:4.12.1'
testImplementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.12.1'
testImplementation "com.github.tomakehurst:wiremock-jre8-standalone:2.35.0"
testImplementation "com.github.dasniko:testcontainers-keycloak:${keycloakTestcontainersVersion}"
testImplementation "org.testcontainers:selenium:${testcontainersVersion}"
testImplementation "org.seleniumhq.selenium:selenium-java:${seleniumVersion}"
testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:${seleniumVersion}"
testImplementation "com.github.tomakehurst:wiremock-jre8-standalone:${wiremockVersion}"
testImplementation 'com.jayway.jsonpath:json-path-assert:2.7.0'
testImplementation project(":pn-shared-test-modules:common")
testImplementation 'com.github.stefanbirkner:system-lambda:1.2.1'

contractTestImplementation project(":pn-shared-test-modules:common")
contractTestRuntimeClasspath getStubsJarFromProject(':pn-user-service')
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${springCloudVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

Expand Down Expand Up @@ -100,6 +95,8 @@ tasks.register('integrationTest', Test) {
}
}

tasks.findByName('integrationTest').dependsOn('jar')

idea {
module {
sourceDirs -= project.sourceSets.integTest.groovy.srcDirs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package io.mkrzywanski.keycloak.listeners

import com.github.tomakehurst.wiremock.client.WireMock
import io.mkrzywanski.keycloak.listeners.UserServicePropertiesProvider
import io.mkrzywanski.shared.keycloak.*
import dasniko.testcontainers.keycloak.KeycloakContainer
import io.mkrzywanski.shared.keycloak.KeyCloakAccess
import io.mkrzywanski.shared.keycloak.KeyCloakProperties
import io.mkrzywanski.shared.keycloak.KeycloakClient
import io.mkrzywanski.shared.keycloak.KeycloakUser
import org.keycloak.admin.client.Keycloak
import org.keycloak.admin.client.KeycloakBuilder
import org.keycloak.admin.client.resource.RealmResource
import org.keycloak.representations.idm.ClientRepresentation
Expand Down Expand Up @@ -30,9 +34,10 @@ import static org.testcontainers.shaded.org.awaitility.Awaitility.await

class ListenerTest extends Specification {

static def VALID_REDIRECT_URI = "http://localhost:5555"
def network = Network.newNetwork()
def properties = keyCloakProperties()
def keycloak = keyCloakContainer(properties, network)
def keycloak = keyCloakContainer(network)
def access

def wiremock = new GenericContainer("wiremock/wiremock:2.32.0")
Expand All @@ -51,9 +56,10 @@ class ListenerTest extends Specification {
wiremockClient = new WireMock("localhost", wiremock.getFirstMappedPort())

keycloak.withEnv(UserServicePropertiesProvider.USER_SERVICE_URL_ENV, "http://wiremock:8080")
keycloak.portBindings = List.of("8080:8080")
keycloak.start()
access = keycloak(properties, keycloak)
setupKeycloak(properties, keycloak.getFirstMappedPort())
setupKeycloak(properties, keycloak.keycloakAdminClient)

selenium.start()
driver = new RemoteWebDriver(selenium.getSeleniumAddress(), new ChromeOptions())
Expand Down Expand Up @@ -104,8 +110,10 @@ class ListenerTest extends Specification {
}

def registrationIsPerformed() {
driver.navigate().to("http://keycloak:8080/auth/realms/${properties.testRealm}/protocol/openid-connect/auth?response_type=code&client_id=${properties.client.clientId}&scope=openid&redirect_uri=http://localhost:5555")
driver.navigate().to("http://keycloak:8080/realms/${properties.testRealm}/protocol/openid-connect/auth?response_type=code&client_id=${properties.client.clientId}&scope=openid&redirect_uri=${VALID_REDIRECT_URI}")

driver.findElement(By.linkText("Register")).click()

driver.findElement(By.id("firstName")).sendKeys("test")
driver.findElement(By.id("lastName")).sendKeys("test")
driver.findElement(By.id("email")).sendKeys("[email protected]")
Expand All @@ -115,10 +123,10 @@ class ListenerTest extends Specification {
driver.findElement(By.cssSelector("input[type='submit']")).submit()
}

KeyCloakContainer keyCloakContainer(final KeyCloakProperties keyCloakProperties, final Network network) {
KeycloakContainer keyCloakContainer(final Network network) {
def listenerJarPath = new File("build/libs").listFiles().first().path
new KeyCloakContainer(keyCloakProperties.adminUser)
.withCopyFileToContainer(MountableFile.forHostPath(listenerJarPath, 0744), "/opt/jboss/keycloak/standalone/deployments/user-registered-listener.jar")
new KeycloakContainer()
.withCopyFileToContainer(MountableFile.forHostPath(listenerJarPath, 0744), "/opt/keycloak/providers/user-registered-listener.jar")
.withNetwork(network)
.withNetworkAliases("keycloak")
}
Expand All @@ -130,14 +138,8 @@ class ListenerTest extends Specification {
new KeyCloakProperties(client, KeyCloakProperties.ADMIN_CLI_CLIENT, user, admin, "test")
}

KeyCloakAccess keycloak(KeyCloakProperties keyCloakProperties, KeyCloakContainer keyCloakContainer) {
def adminAccess = KeycloakBuilder.builder()
.serverUrl("http://localhost:${keyCloakContainer.getFirstMappedPort()}/auth")
.realm("master")
.clientId(keyCloakProperties.adminCliClient.clientId)
.username(keyCloakProperties.adminUser.username)
.password(keyCloakProperties.adminUser.password)
.build()
KeyCloakAccess keycloak(KeyCloakProperties keyCloakProperties, KeycloakContainer keyCloakContainer) {
def adminAccess = keyCloakContainer.keycloakAdminClient
def userAccess = KeycloakBuilder.builder()
.serverUrl("http://localhost:${keyCloakContainer.getFirstMappedPort()}/auth")
.realm(keyCloakProperties.testRealm)
Expand All @@ -149,15 +151,7 @@ class ListenerTest extends Specification {
new KeyCloakAccess(adminAccess, userAccess)
}

static def setupKeycloak(KeyCloakProperties keyCloakProperties,
int port) {
def keycloak = KeycloakBuilder.builder()
.serverUrl("http://localhost:${port}/auth")
.realm("master")
.clientId(keyCloakProperties.adminCliClient.clientId)
.username(keyCloakProperties.adminUser.username)
.password(keyCloakProperties.adminUser.password)
.build()
static def setupKeycloak(KeyCloakProperties keyCloakProperties, Keycloak keycloak) {

def realm = testRealm(keyCloakProperties.testRealm)
keycloak.realms().create(realm)
Expand Down Expand Up @@ -199,6 +193,8 @@ class ListenerTest extends Specification {
clientRepresentation.directAccessGrantsEnabled = true
clientRepresentation.standardFlowEnabled = true
clientRepresentation.serviceAccountsEnabled = true
clientRepresentation.implicitFlowEnabled = true
clientRepresentation.redirectUris = List.of(VALID_REDIRECT_URI)
clientRepresentation
}
}
Loading

0 comments on commit bbf3920

Please sign in to comment.