Skip to content

Commit

Permalink
Make the app id and private key optional in tests
Browse files Browse the repository at this point in the history
Fixes #280
  • Loading branch information
yrodiere committed Sep 8, 2022
1 parent 7f5e4f2 commit 978708a
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReplayEventRouteAvailableInDevModeTest {
@RegisterExtension
public static final QuarkusDevModeTest test = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource("application.properties"));
.addAsResource("application-for-dev.properties", "application.properties"));

@Test
public void testPayloadSignatureCheck() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class PayloadSignatureCheckerTest {
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(PayloadUtil.class)
.addAsResource(PAYLOAD))
.withConfigurationResource("application.properties");
.withConfigurationResource("application.properties")
.overrideConfigKey("quarkus.github-app.webhook-secret", "cs5WKyOlY6go0E1RbkAOf0jq5K4KWBcP");

@Inject
PayloadSignatureChecker payloadSignatureChecker;
Expand Down
31 changes: 31 additions & 0 deletions deployment/src/test/resources/application-for-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Don't name this file application-dev.properties or it will get picked up
# for every single test, including those that don't reference this file...
quarkus.github-app.app-id=1234
quarkus.github-app.app-name=quarkus-github-app-test
quarkus.github-app.private-key=-----BEGIN RSA PRIVATE KEY-----\
MIIEowIBAAKCAQEAtsCKYkMzgqSsbkcPThTjeYnd6r5RAS4q5SyiOyIf34nYH5D0\
jy8Dlt1s8u69KmBoM9Neesqf2Yh80b/UNUtea9knpgR4ME+MIg1LdsLnUWoZuPBl\
lLaMfwRkN4+ZbTJ7Uo98UUlxoTcCjZVzopSoIazuUF5u+01sx6QEcHB312s42FVL\
gkd8T36wvIywseOPKr2oyCMQ2AdcxL/cEHwx2hcQAe+eTipsxNy4atIhbDWrML5W\
v7cYlyn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0kgWbXNzZ0rm31k3zI6vXt7iZy5NKU+AtPsk\
pzwANJwZ0wzltgRGG9gpz2Lls3DJMRNZxvppL3wu74YKdr+kJxvbhjz0Z+304dCF\
YaGsVwKBgA6KSf1pPD93W/v5tV0WnhBZGKb3sX34JLQoCJPS5w6nTjHnuwpP9g0K\
C8HXKULXuX/rb/gz99PNcPQ9GqB0Rw/ho1KhO3VLJjBiSh/hiASKuFGs2y59UXYt\
mvqX3jAqi6ksGD5WPG6G2CdL/n30e5/lc10hq7SiwV7z9njW/8Pu\
-----END RSA PRIVATE KEY-----
31 changes: 1 addition & 30 deletions deployment/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
quarkus.github-app.app-id=88937
quarkus.github-app.app-name=quarkus-github-app-test
quarkus.github-app.webhook-secret=cs5WKyOlY6go0E1RbkAOf0jq5K4KWBcP
quarkus.github-app.private-key=-----BEGIN RSA PRIVATE KEY-----\
MIIEowIBAAKCAQEAtsCKYkMzgqSsbkcPThTjeYnd6r5RAS4q5SyiOyIf34nYH5D0\
jy8Dlt1s8u69KmBoM9Neesqf2Yh80b/UNUtea9knpgR4ME+MIg1LdsLnUWoZuPBl\
lLaMfwRkN4+ZbTJ7Uo98UUlxoTcCjZVzopSoIazuUF5u+01sx6QEcHB312s42FVL\
gkd8T36wvIywseOPKr2oyCMQ2AdcxL/cEHwx2hcQAe+eTipsxNy4atIhbDWrML5W\
v7cYlyn9/sKgxkXtW3eInP3VI3FS+IH+cjwO4FS6ez8TT6USfaCjDb4LgdEKt/de\
Ds4TbqwM2vjqedLNBhE7t4V2Uf3STdFq+cKHwwIDAQABAoIBAE07MUA1hh8/2F8C\
SMWGrls+mDoME8+b4yTWp/i1gyLE7kDo0XFxPOMU0GYZ3nd6Jo9AVD0wRD16IMXD\
e7rKDy0kqEzQtroz49TAKZQW6grN+/DcJxGh094ZzQBt/zjWjKdnW/I+R3cJ+Fo9\
PpEGoccZfd0ZC23IWqBEAFxEK2Eth7CbJW5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RSA PRIVATE KEY-----
quarkus.github-app.app-name=quarkus-github-app-test
7 changes: 0 additions & 7 deletions docs/modules/ROOT/pages/includes/attributes.adoc

This file was deleted.

10 changes: 6 additions & 4 deletions docs/modules/ROOT/pages/includes/quarkus-github-app.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ a| [[quarkus-github-app_quarkus.github-app.app-id]]`link:#quarkus-github-app_qua

[.description]
--
The numeric application id provided by GitHub.
The numeric application id provided by GitHub.
Optional for tests, but mandatory in production and dev mode.

Environment variable: `+++QUARKUS_GITHUB_APP_APP_ID+++`
--|string
|required icon:exclamation-circle[title=Configuration property is required]
|


a| [[quarkus-github-app_quarkus.github-app.app-name]]`link:#quarkus-github-app_quarkus.github-app.app-name[quarkus.github-app.app-name]`
Expand Down Expand Up @@ -48,12 +49,13 @@ a| [[quarkus-github-app_quarkus.github-app.private-key]]`link:#quarkus-github-ap

[.description]
--
The RSA private key.
The RSA private key.
Optional for tests, but mandatory in production and dev mode.

Environment variable: `+++QUARKUS_GITHUB_APP_PRIVATE_KEY+++`
--|link:https://docs.oracle.com/javase/8/docs/api/java/security/PrivateKey.html[PrivateKey]

|required icon:exclamation-circle[title=Configuration property is required]
|


a| [[quarkus-github-app_quarkus.github-app.webhook-secret]]`link:#quarkus-github-app_quarkus.github-app.webhook-secret[quarkus.github-app.webhook-secret]`
Expand Down
36 changes: 0 additions & 36 deletions docs/modules/ROOT/pages/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,6 @@ Add the following dependency to your `deployment` module:
</dependency>
----

== Configure the application for tests

Add a fake application ID and private key to your `application.properties`, just for tests:

[source,properties]
------
%test.quarkus.github-app.app-id=0
%test.quarkus.github-app.private-key=-----BEGIN RSA PRIVATE KEY-----\
MIIEogIBAAKCAQEA30YvyuZAd+kGDT0nm/XAa93CqsDvC/iYOc4KsKsfBQs1MWjH\
royuVDfQj2fJvueFnOgZApM3viaCz188D/j3tUMNByIKOfMLiEm/R1tq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0Wn+OGXfk+ddMTo5wk+FeOw831FVfPT3O1xq3tDE5WAdchNQb/BC3G1JRtEs04\
IrD1bwuMD+//m8T+12+97QKBgDko0XhEGdV3+MfkKiphJoe24Pxre3lxl6YhUSuJ\
Mpop9t/9YVuC62WCGRzKaVlZ2ExxXXyU+uMxX999Rq81q/mKq7Xg5kcdIeoRIP8d\
FqD6xNtjmuaS5enErcCAMbZtzA7TNzvGaVO+xB/GfQ2QHS8/mrTesvQsTUZwC+ji\
E0/FAoGATJvuAfgy9uiKR7za7MigYVacE0u4aD1sF7v6D4AFqBOGquPQQhePSdz9\
G/UUwySoo+AQ+rd2EPhyexjqXBhRGe+EDGFVFivaQzTT8/5bt/VddbTcw2IpmXYj\
LW6V8BbcP5MRhd2JQSRh16nWwSQJ2BdpUZFwayEEQ6UcrMfqvA0=\
-----END RSA PRIVATE KEY-----
------

== Add event payloads to the test resources

When you <<manual-vs-automated,tested your application manually>>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
quarkus.application.name=testing-framework-test-app

%test.quarkus.github-app.app-id=0
%test.quarkus.github-app.private-key=-----BEGIN RSA PRIVATE KEY-----\
MIIEogIBAAKCAQEA30YvyuZAd+kGDT0nm/XAa93CqsDvC/iYOc4KsKsfBQs1MWjH\
royuVDfQj2fJvueFnOgZApM3viaCz188D/j3tUMNByIKOfMLiEm/R1tqe7Q6xRRn\
uwpfT+wv+/x4cNvPxTscwo43LVR9Pno71UfZZywnYN03GS71ttNCiiBKXwCSnHez\
/t79iAmMnym7ViNsKzA0aS5EwAw9A3GeTnxpRef0y0vDNE2aXBNCe+f1ZnFq1Fhe\
PJIlKs/qlM136A2co+WRaPghacZJMuwQr1vajuMSBjMEroIPOfSG3x3Oitvnukjp\
EwuhXjmZeaLc+60rYaMRwf+bje8KmaAVOMWkHQIDAQABAoIBAA+d8SnYARpiCjJS\
3Lpj7hmdYUhgRlgoAz3H06eX0IuhxQ63rX/gBzGM1eGx+MKJnybidR1g/r0mJHAs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oo+AQ+rd2EPhyexjqXBhRGe+EDGFVFivaQzTT8/5bt/VddbTcw2IpmXYj\
LW6V8BbcP5MRhd2JQSRh16nWwSQJ2BdpUZFwayEEQ6UcrMfqvA0=\
-----END RSA PRIVATE KEY-----
quarkus.application.name=testing-framework-test-app
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ public class GitHubAppRuntimeConfig {

/**
* The numeric application id provided by GitHub.
* <p>
* Optional for tests, but mandatory in production and dev mode.
*/
@ConfigItem
public String appId;
public Optional<String> appId;

/**
* The GitHub name of the application.
Expand All @@ -35,10 +37,12 @@ public class GitHubAppRuntimeConfig {

/**
* The RSA private key.
* <p>
* Optional for tests, but mandatory in production and dev mode.
*/
@ConfigItem
@ConvertWith(PrivateKeyConverter.class)
public PrivateKey privateKey;
public Optional<PrivateKey> privateKey;

/**
* The webhook secret if defined in the GitHub UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.kohsuke.github.GHAppInstallationToken;
Expand All @@ -21,6 +25,9 @@
import io.quarkiverse.githubapp.GitHubClientProvider;
import io.quarkiverse.githubapp.runtime.config.GitHubAppRuntimeConfig;
import io.quarkiverse.githubapp.runtime.signing.JwtTokenCreator;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder;

Expand All @@ -32,14 +39,17 @@ public class GitHubService implements GitHubClientProvider {

private final GitHubAppRuntimeConfig gitHubAppRuntimeConfig;

private final JwtTokenCreator jwtTokenCreator;
private final JwtTokenProvider jwtTokenProvider;

private final LoadingCache<Long, CachedInstallationToken> installationTokenCache;

@Inject
LaunchMode launchMode;

@Inject
public GitHubService(GitHubAppRuntimeConfig gitHubAppRuntimeConfig, JwtTokenCreator jwtTokenCreator) {
this.gitHubAppRuntimeConfig = gitHubAppRuntimeConfig;
this.jwtTokenCreator = jwtTokenCreator;
this.jwtTokenProvider = new JwtTokenProvider(gitHubAppRuntimeConfig, jwtTokenCreator);
this.installationTokenCache = Caffeine.newBuilder()
.maximumSize(50)
.expireAfter(new Expiry<Long, CachedInstallationToken>() {
Expand Down Expand Up @@ -69,6 +79,20 @@ public long expireAfterRead(Long installationId, CachedInstallationToken cachedI
.build(new CreateInstallationToken());
}

public void init(@Observes StartupEvent startupEvent) throws IOException {
switch (launchMode) {
case TEST:
// If some client config is missing, we'll fail later, and only if tests attempt to retrieve the client.
break;
case NORMAL:
case DEVELOPMENT:
default:
// If some client config is missing, we'll fail on startup.
jwtTokenProvider.checkConfig();
break;
}
}

@Override
public GitHub getInstallationClient(long installationId) {
try {
Expand Down Expand Up @@ -179,8 +203,7 @@ private GitHub createApplicationGitHub() {
String jwtToken;

try {
// maximum TTL is 10 minutes
jwtToken = jwtTokenCreator.createJwtToken(gitHubAppRuntimeConfig.appId, gitHubAppRuntimeConfig.privateKey, 540);
jwtToken = jwtTokenProvider.createJwtToken();
} catch (GeneralSecurityException | IOException e) {
throw new IllegalStateException("Unable to generate the JWT token", e);
}
Expand All @@ -195,4 +218,45 @@ private GitHub createApplicationGitHub() {
throw new IllegalStateException("Unable to create a GitHub client for the application", e);
}
}

private static class JwtTokenProvider {
private final String appId;
private final PrivateKey privateKey;
private final Set<String> missingPropertyKeys = new HashSet<>();
private final JwtTokenCreator jwtTokenCreator;

public JwtTokenProvider(GitHubAppRuntimeConfig gitHubAppRuntimeConfig, JwtTokenCreator jwtTokenCreator) {
this.jwtTokenCreator = jwtTokenCreator;
if (gitHubAppRuntimeConfig.appId.isPresent()) {
appId = gitHubAppRuntimeConfig.appId.get();
} else {
appId = null;
missingPropertyKeys.add("quarkus.github-app.app-id");
}
if (gitHubAppRuntimeConfig.privateKey.isPresent()) {
privateKey = gitHubAppRuntimeConfig.privateKey.get();
} else {
privateKey = null;
missingPropertyKeys.add("quarkus.github-app.private-key");
}
}

public String createJwtToken() throws GeneralSecurityException, IOException {
checkConfig();
// maximum TTL is 10 minutes
return jwtTokenCreator.createJwtToken(appId, privateKey, 540);
}

public void checkConfig() {
if (!missingPropertyKeys.isEmpty()) {
throw new ConfigurationException(
"Missing value for configuration properties " + missingPropertyKeys + "."
+ " This configuration is necessary to create the GitHub clients."
+ " It is optional only in tests, if GitHub clients are being mocked using quarkus-github-app-testing"
+ " (see https://quarkiverse.github.io/quarkiverse-docs/quarkus-github-app/dev/testing.html).",
missingPropertyKeys);
}
}

}
}

0 comments on commit 978708a

Please sign in to comment.