24
24
import java .time .temporal .ChronoUnit ;
25
25
26
26
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 ;
27
30
import org .shredzone .acme4j .AccountBuilder ;
28
31
import org .shredzone .acme4j .Authorization ;
29
32
import org .shredzone .acme4j .Certificate ;
@@ -49,8 +52,10 @@ public class OrderIT extends PebbleITBase {
49
52
/**
50
53
* Test if a certificate can be ordered via http-01 challenge.
51
54
*/
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 {
54
59
orderCertificate (TEST_DOMAIN , auth -> {
55
60
var client = getBammBammClient ();
56
61
@@ -61,14 +66,16 @@ public void testHttpValidation() throws Exception {
61
66
cleanup (() -> client .httpRemoveToken (challenge .getToken ()));
62
67
63
68
return challenge ;
64
- }, OrderIT ::standardRevoker );
69
+ }, OrderIT ::standardRevoker , profile );
65
70
}
66
71
67
72
/**
68
73
* Test if a certificate can be ordered via dns-01 challenge.
69
74
*/
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 {
72
79
orderCertificate (TEST_DOMAIN , auth -> {
73
80
var client = getBammBammClient ();
74
81
@@ -81,14 +88,16 @@ public void testDnsValidation() throws Exception {
81
88
cleanup (() -> client .dnsRemoveTxtRecord (challengeDomainName ));
82
89
83
90
return challenge ;
84
- }, OrderIT ::standardRevoker );
91
+ }, OrderIT ::standardRevoker , profile );
85
92
}
86
93
87
94
/**
88
95
* Test if a certificate can be ordered via tns-alpn-01 challenge.
89
96
*/
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 {
92
101
orderCertificate (TEST_DOMAIN , auth -> {
93
102
var client = getBammBammClient ();
94
103
@@ -101,7 +110,7 @@ public void testTlsAlpnValidation() throws Exception {
101
110
cleanup (() -> client .tlsAlpnRemoveCertificate (auth .getIdentifier ().getDomain ()));
102
111
103
112
return challenge ;
104
- }, OrderIT ::standardRevoker );
113
+ }, OrderIT ::standardRevoker , profile );
105
114
}
106
115
107
116
/**
@@ -119,7 +128,7 @@ public void testDomainKeyRevocation() throws Exception {
119
128
cleanup (() -> client .httpRemoveToken (challenge .getToken ()));
120
129
121
130
return challenge ;
122
- }, OrderIT ::domainKeyRevoker );
131
+ }, OrderIT ::domainKeyRevoker , null );
123
132
}
124
133
125
134
/**
@@ -132,8 +141,10 @@ public void testDomainKeyRevocation() throws Exception {
132
141
* validation
133
142
* @param revoker
134
143
* {@link Revoker} that finally revokes the certificate
144
+ * @param profile
145
+ * Profile to be used, or {@code null} for no profile selection.
135
146
*/
136
- private void orderCertificate (String domain , Validator validator , Revoker revoker )
147
+ private void orderCertificate (String domain , Validator validator , Revoker revoker , String profile )
137
148
throws Exception {
138
149
var keyPair = createKeyPair ();
139
150
var session = new Session (pebbleURI ());
@@ -148,15 +159,26 @@ private void orderCertificate(String domain, Validator validator, Revoker revoke
148
159
var notBefore = Instant .now ().truncatedTo (ChronoUnit .SECONDS );
149
160
var notAfter = notBefore .plus (Duration .ofDays (20L ));
150
161
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 ();
156
172
assertThat (order .getNotBefore ().orElseThrow ()).isEqualTo (notBefore );
157
173
assertThat (order .getNotAfter ().orElseThrow ()).isEqualTo (notAfter );
158
174
assertThat (order .getStatus ()).isEqualTo (Status .PENDING );
159
175
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
+
160
182
for (var auth : order .getAuthorizations ()) {
161
183
assertThat (auth .getIdentifier ().getDomain ()).isEqualTo (domain );
162
184
assertThat (auth .getStatus ()).isEqualTo (Status .PENDING );
0 commit comments