Skip to content

Commit 6b0b0e6

Browse files
committed
Add IT for Pebble profile
1 parent f6a3bd6 commit 6b0b0e6

File tree

1 file changed

+38
-16
lines changed
  • acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble

1 file changed

+38
-16
lines changed

acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderIT.java

+38-16
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import java.time.temporal.ChronoUnit;
2525

2626
import org.junit.jupiter.api.Test;
27+
import org.junit.jupiter.params.ParameterizedTest;
28+
import org.junit.jupiter.params.provider.NullSource;
29+
import org.junit.jupiter.params.provider.ValueSource;
2730
import org.shredzone.acme4j.AccountBuilder;
2831
import org.shredzone.acme4j.Authorization;
2932
import org.shredzone.acme4j.Certificate;
@@ -49,8 +52,10 @@ public class OrderIT extends PebbleITBase {
4952
/**
5053
* Test if a certificate can be ordered via http-01 challenge.
5154
*/
52-
@Test
53-
public void testHttpValidation() throws Exception {
55+
@ParameterizedTest
56+
@NullSource
57+
@ValueSource(strings = {"default", "shortlived"})
58+
public void testHttpValidation(String profile) throws Exception {
5459
orderCertificate(TEST_DOMAIN, auth -> {
5560
var client = getBammBammClient();
5661

@@ -61,14 +66,16 @@ public void testHttpValidation() throws Exception {
6166
cleanup(() -> client.httpRemoveToken(challenge.getToken()));
6267

6368
return challenge;
64-
}, OrderIT::standardRevoker);
69+
}, OrderIT::standardRevoker, profile);
6570
}
6671

6772
/**
6873
* Test if a certificate can be ordered via dns-01 challenge.
6974
*/
70-
@Test
71-
public void testDnsValidation() throws Exception {
75+
@ParameterizedTest
76+
@NullSource
77+
@ValueSource(strings = {"default", "shortlived"})
78+
public void testDnsValidation(String profile) throws Exception {
7279
orderCertificate(TEST_DOMAIN, auth -> {
7380
var client = getBammBammClient();
7481

@@ -81,14 +88,16 @@ public void testDnsValidation() throws Exception {
8188
cleanup(() -> client.dnsRemoveTxtRecord(challengeDomainName));
8289

8390
return challenge;
84-
}, OrderIT::standardRevoker);
91+
}, OrderIT::standardRevoker, profile);
8592
}
8693

8794
/**
8895
* Test if a certificate can be ordered via tns-alpn-01 challenge.
8996
*/
90-
@Test
91-
public void testTlsAlpnValidation() throws Exception {
97+
@ParameterizedTest
98+
@NullSource
99+
@ValueSource(strings = {"default", "shortlived"})
100+
public void testTlsAlpnValidation(String profile) throws Exception {
92101
orderCertificate(TEST_DOMAIN, auth -> {
93102
var client = getBammBammClient();
94103

@@ -101,7 +110,7 @@ public void testTlsAlpnValidation() throws Exception {
101110
cleanup(() -> client.tlsAlpnRemoveCertificate(auth.getIdentifier().getDomain()));
102111

103112
return challenge;
104-
}, OrderIT::standardRevoker);
113+
}, OrderIT::standardRevoker, profile);
105114
}
106115

107116
/**
@@ -119,7 +128,7 @@ public void testDomainKeyRevocation() throws Exception {
119128
cleanup(() -> client.httpRemoveToken(challenge.getToken()));
120129

121130
return challenge;
122-
}, OrderIT::domainKeyRevoker);
131+
}, OrderIT::domainKeyRevoker, null);
123132
}
124133

125134
/**
@@ -132,8 +141,10 @@ public void testDomainKeyRevocation() throws Exception {
132141
* validation
133142
* @param revoker
134143
* {@link Revoker} that finally revokes the certificate
144+
* @param profile
145+
* Profile to be used, or {@code null} for no profile selection.
135146
*/
136-
private void orderCertificate(String domain, Validator validator, Revoker revoker)
147+
private void orderCertificate(String domain, Validator validator, Revoker revoker, String profile)
137148
throws Exception {
138149
var keyPair = createKeyPair();
139150
var session = new Session(pebbleURI());
@@ -148,15 +159,26 @@ private void orderCertificate(String domain, Validator validator, Revoker revoke
148159
var notBefore = Instant.now().truncatedTo(ChronoUnit.SECONDS);
149160
var notAfter = notBefore.plus(Duration.ofDays(20L));
150161

151-
var order = account.newOrder()
152-
.domain(domain)
153-
.notBefore(notBefore)
154-
.notAfter(notAfter)
155-
.create();
162+
var orderBuilder = account.newOrder()
163+
.domain(domain)
164+
.notBefore(notBefore)
165+
.notAfter(notAfter);
166+
167+
if (profile != null) {
168+
orderBuilder.profile(profile);
169+
}
170+
171+
var order = orderBuilder.create();
156172
assertThat(order.getNotBefore().orElseThrow()).isEqualTo(notBefore);
157173
assertThat(order.getNotAfter().orElseThrow()).isEqualTo(notAfter);
158174
assertThat(order.getStatus()).isEqualTo(Status.PENDING);
159175

176+
if (profile != null) {
177+
assertThat(order.getProfile()).contains(profile);
178+
} else {
179+
// FIXME: Pebble falls back to different values here, cannot be tested properly
180+
}
181+
160182
for (var auth : order.getAuthorizations()) {
161183
assertThat(auth.getIdentifier().getDomain()).isEqualTo(domain);
162184
assertThat(auth.getStatus()).isEqualTo(Status.PENDING);

0 commit comments

Comments
 (0)