Skip to content

Commit

Permalink
Quarkus Gradle Plugin: tests with encrypted configuration
Browse files Browse the repository at this point in the history
As decribed in #33135, using encrypted configuration values did not
work with the Gradle plugin since Quarkus 3.0.0, prior to SmallRye
Config 3.3.0 (#33079).

This change just adds tests to validate the behavior.
  • Loading branch information
snazy committed Oct 9, 2023
1 parent 6be99a4 commit 1db964e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.gradle.tasks;

import java.io.File;
import java.net.URL;
import java.nio.file.Path;

import org.apache.commons.io.FileUtils;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class CryptoConfigTest {

@TempDir
Path testProjectDir;

@Test
void smallryeCrypto() throws Exception {
URL url = getClass().getClassLoader().getResource("io/quarkus/gradle/tasks/crypto/main");
FileUtils.copyDirectory(new File(url.toURI()), testProjectDir.toFile());
FileUtils.copyFile(new File("../gradle.properties"), testProjectDir.resolve("gradle.properties").toFile());

GradleRunner.create()
.withPluginClasspath()
.withProjectDir(testProjectDir.toFile())
.withArguments("build", "--info", "--stacktrace", "--build-cache", "--configuration-cache")
// .build() checks whether the build failed, which is good enough for this test
.build();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ void fromForcedProperties() {
soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "bar");
}

@Test
void crypto() {
EffectiveConfig effectiveConfig = EffectiveConfig.builder()
.withTaskProperties(Map.of("quarkus.foo", "${aes-gcm-nopadding::superSecret}")).build();

soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "superSecret");
}

@ParameterizedTest
@ValueSource(strings = {
"app-props-and-yaml",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
java
id("io.quarkus")
}

buildscript {
repositories {
mavenLocal()
mavenCentral()
}
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
implementation(enforcedPlatform("io.quarkus:quarkus-bom:${project.property("version")}"))
implementation("jakarta.inject:jakarta.inject-api:2.0.1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "gradle-build-caching"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.acme;

public class Foo {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
someValue = ${aes-gcm-nopadding::superSecret}

0 comments on commit 1db964e

Please sign in to comment.