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 quarkusio#33135, using encrypted configuration values did not
work with the Gradle plugin since Quarkus 3.0.0, prior to SmallRye
Config 3.3.0 (quarkusio#33079).

This change just adds tests to validate the behavior.
  • Loading branch information
snazy committed Feb 8, 2024
1 parent 4151049 commit 564299d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class CryptoConfigTest {

@TempDir
Path testProjectDir;

@Test
@Disabled("To be fixed via https://github.com/quarkusio/quarkus/issues/38007")
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 @@ -12,6 +12,7 @@
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.junit.jupiter.InjectSoftAssertions;
import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand Down Expand Up @@ -49,6 +50,15 @@ void fromForcedProperties() {
soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "bar");
}

@Test
@Disabled("To be fixed via https://github.com/quarkusio/quarkus/issues/38007")
void crypto() {
EffectiveConfig effectiveConfig = EffectiveConfig.builder()
.withTaskProperties(Map.of("quarkus.foo", "${aes-gcm-nopadding::superSecret}")).build();

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

@Test
void appPropsOverload() throws Exception {
URL url1 = getClass().getClassLoader().getResource("io/quarkus/gradle/tasks/effectiveConfig/overload/1/");
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 564299d

Please sign in to comment.