Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #270 - Add generating of certificate to Dockerfile #271

Merged
merged 1 commit into from
Dec 7, 2023
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
1 change: 1 addition & 0 deletions azure-keyvault/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<run>
<ports>
<port>8080:8080</port>
<port>8443:8443</port>
</ports>
<wait>
<http>
Expand Down
7 changes: 6 additions & 1 deletion azure-keyvault/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM ghcr.io/piranhacloud/webprofile:23.10.0
ADD target/ROOT.war /home/piranha
CMD ["java", "-jar", "piranha-dist-webprofile.jar", "--war-file", "ROOT.war"]
ADD src/main/docker/startup.sh /home/piranha
WORKDIR /home/piranha
USER piranha
RUN mkdir certs && \
keytool -genkey -alias self-signed -keyalg RSA -keystore certs/keystore.jks -keysize 4096 -storepass password -dname "CN=localhost"
CMD ["sh", "./startup.sh"]
6 changes: 6 additions & 0 deletions azure-keyvault/src/main/docker/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

#
# Run the application
#
java -jar piranha-dist-webprofile.jar --war-file ROOT.war --https-port 8443 --https-keystore-file certs/keystore.jks --https-keystore-password password
57 changes: 57 additions & 0 deletions azure-keyvault/src/test/java/keyvault/KeyVaultIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package keyvault;

import com.azure.core.credential.TokenCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.SecretClientBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* The integration tests to test our simulated Azure Key Vault.
*
* @author Manfred Riem ([email protected])
*/
public class KeyVaultIT {

private TokenCredential credential;

public KeyVaultIT() {
}

@BeforeAll
public static void setUpClass() {
}

@AfterAll
public static void tearDownClass() {
}

@BeforeEach
public void setUp() {
credential = new DefaultAzureCredentialBuilder().build();
}

@AfterEach
public void tearDown() {
}

@Test
@Disabled
public void testGetSecret() {
String keyVaultUri = "https://localhost:8443/api";

SecretClient keyClient = new SecretClientBuilder()
.disableChallengeResourceVerification()
.vaultUrl(keyVaultUri)
.credential(credential)
.buildClient();

assertEquals("secretValue", keyClient.getSecret("secretKey"));
}
}