Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

VERSION=$(grep 'version' build.gradle | cut -f 2 -d "'")
VERSION=$(grep 'version =' build.gradle.kts | cut -f 2 -d '"')

if [ ! -f "build/httpbucket-$VERSION-runner" ]
then
Expand Down
26 changes: 17 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm") version "1.9.24"
kotlin("plugin.allopen") version "1.9.24"
kotlin("jvm") version "2.0.21"
kotlin("plugin.allopen") version "2.0.21"
id("io.quarkus")
}

Expand All @@ -14,7 +16,11 @@ val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project

dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation(
enforcedPlatform(
"$quarkusPlatformGroupId:$quarkusPlatformArtifactId:$quarkusPlatformVersion",
),
)
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("io.smallrye.config:smallrye-config-source-file-system")
implementation("io.quarkus:quarkus-micrometer-registry-prometheus")
Expand All @@ -33,7 +39,7 @@ dependencies {
}

group = "com.testainers"
version = "0.1.1"
version = "0.1.2"

java {
sourceCompatibility = JavaVersion.VERSION_21
Expand All @@ -43,7 +49,7 @@ java {
tasks.withType<Test> {
systemProperty(
"java.util.logging.manager",
"org.jboss.logmanager.LogManager"
"org.jboss.logmanager.LogManager",
)

testLogging {
Expand All @@ -52,7 +58,7 @@ tasks.withType<Test> {
"SKIPPED",
"FAILED",
"STANDARD_OUT",
"STANDARD_ERROR"
"STANDARD_ERROR",
)
}
}
Expand All @@ -64,7 +70,9 @@ allOpen {
annotation("io.quarkus.test.junit.QuarkusTest")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_21.toString()
kotlinOptions.javaParameters = true
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
javaParameters = true
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Gradle properties
quarkusPluginId=io.quarkus
quarkusPluginVersion=3.11.0
quarkusPluginVersion=3.18.3
quarkusPlatformGroupId=io.quarkus.platform
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformVersion=3.11.0
quarkusPlatformVersion=3.18.3
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.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pluginManagement {
id(quarkusPluginId) version quarkusPluginVersion
}
}
rootProject.name="httpbucket"
rootProject.name = "httpbucket"
4 changes: 3 additions & 1 deletion src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
# accessed directly. (example: "foo.example.com,bar.example.com")
#
###
FROM registry.access.redhat.com/ubi8/openjdk-21:1.18
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20

ENV LANGUAGE='en_US:en'

Expand All @@ -88,7 +88,9 @@ COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080

USER 185

ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

Expand Down
5 changes: 3 additions & 2 deletions src/main/docker/Dockerfile.legacy-jar
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@
# accessed directly. (example: "foo.example.com,bar.example.com")
#
###
FROM registry.access.redhat.com/ubi8/openjdk-21:1.18
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20

ENV LANGUAGE='en_US:en'


COPY build/lib/* /deployments/lib/
COPY build/*-runner.jar /deployments/quarkus-run.jar

EXPOSE 8080

USER 185

ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

Expand Down
6 changes: 5 additions & 1 deletion src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
# docker run -i --rm -p 8080:8080 quarkus/httpbucket
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10

WORKDIR /work/

RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work

COPY --chown=1001:root build/*-runner /work/application

EXPOSE 8080

USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
2 changes: 2 additions & 0 deletions src/main/docker/Dockerfile.native-micro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#
###
FROM quay.io/quarkus/quarkus-micro-image:2.0

WORKDIR /work/

RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/com/testainers/BasicAuthResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class BasicAuthResource(
body: Any?,
): Response = getResponse(auth, user, pass, body)

@HEAD
fun head(
@RestHeader(HttpHeaders.AUTHORIZATION) auth: String?,
user: String,
pass: String,
): Response = getResponse(auth, user, pass, null)

private fun getResponse(
auth: String?,
user: String,
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/com/testainers/DelayResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class DelayResource(
body: Any?,
): Response = internal(delay, body)

@HEAD
fun head(
@Parameter(
description = "Delay must be between 0 and 10 seconds.",
schema = Schema(minimum = "0", maximum = "10", defaultValue = "10"),
) delay: Int,
): Response = internal(delay, null)

private fun internal(
delay: Int,
body: Any?,
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/com/testainers/RedirectResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ class RedirectResource {
) @QueryParam("code") @DefaultValue("302") code: Int,
): Response = internal(url, code)

@HEAD
fun head(
@Parameter(
description = "URL to redirect.",
required = true,
) @QueryParam("url") @DefaultValue("") url: String,
@Parameter(
description = "Response status code.",
schema = Schema(minimum = "300", maximum = "399"),
) @QueryParam("code") @DefaultValue("302") code: Int,
): Response = internal(url, code)

private fun internal(
url: String,
code: Int,
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/com/testainers/StatusResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ class StatusResource(
body: Any?,
): Response = internal(code, body)

@HEAD
fun head(
@Parameter(
description =
"Code must be between 200 and 599. " +
"Informational responses (1XX) are not supported.",
schema = Schema(minimum = "200", maximum = "599"),
) code: Int,
): Response = internal(code, null)

private fun internal(
code: Int,
body: Any?,
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ quarkus.http.cors.access-control-max-age=24H
#
quarkus.info.path=/info
#
quarkus.health.openapi.included=true
quarkus.smallrye-health.root-path=/health
#
quarkus.micrometer.export.prometheus.path=/metrics
Expand Down
12 changes: 9 additions & 3 deletions src/test/kotlin/com/testainers/BaseResourceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract class BaseResourceTest {
Method.PUT,
Method.DELETE,
Method.PATCH,
Method.HEAD,
)

@JvmStatic
Expand All @@ -32,12 +33,17 @@ abstract class BaseResourceTest {
argumentGenerator(listOf(null, "", " ", "a", "1.8"))

@JvmStatic
fun argumentGenerator(list: List<Any?>): List<Arguments> {
fun argumentGenerator(
list: List<Any?>,
remove: List<Method> = listOf(),
): List<Arguments> {
val result = mutableListOf<Arguments>()

methods.forEach { method ->
list.forEach { status ->
result.add(Arguments.of(method, status))
if(method !in remove) {
list.forEach { status ->
result.add(Arguments.of(method, status))
}
}
}

Expand Down
Loading