mirror of https://github.com/shred/acme4j
Fix deprecated warnings
parent
95614e73c5
commit
bd485c23ef
|
@ -43,6 +43,7 @@ public class OrderTest {
|
|||
* Test that order is properly updated.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testUpdate() throws Exception {
|
||||
TestableConnectionProvider provider = new TestableConnectionProvider() {
|
||||
@Override
|
||||
|
@ -71,6 +72,9 @@ public class OrderTest {
|
|||
assertThat(order.getLocation(), is(locationUrl));
|
||||
|
||||
assertThat(order.getDomains(), containsInAnyOrder("example.com", "www.example.com"));
|
||||
assertThat(order.getIdentifiers(), containsInAnyOrder(
|
||||
Identifier.dns("example.com"),
|
||||
Identifier.dns("www.example.com")));
|
||||
assertThat(order.getNotBefore(), is(parseTimestamp("2016-01-01T00:00:00Z")));
|
||||
assertThat(order.getNotAfter(), is(parseTimestamp("2016-01-08T00:00:00Z")));
|
||||
assertThat(order.getCertificate().getLocation(), is(url("https://example.com/acme/cert/1234")));
|
||||
|
@ -138,6 +142,7 @@ public class OrderTest {
|
|||
* Test that order is properly finalized.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testFinalize() throws Exception {
|
||||
byte[] csr = TestUtils.getResourceAsByteArray("/csr.der");
|
||||
|
||||
|
@ -179,6 +184,9 @@ public class OrderTest {
|
|||
assertThat(order.getLocation(), is(locationUrl));
|
||||
|
||||
assertThat(order.getDomains(), containsInAnyOrder("example.com", "www.example.com"));
|
||||
assertThat(order.getIdentifiers(), containsInAnyOrder(
|
||||
Identifier.dns("example.com"),
|
||||
Identifier.dns("www.example.com")));
|
||||
assertThat(order.getNotBefore(), is(parseTimestamp("2016-01-01T00:00:00Z")));
|
||||
assertThat(order.getNotAfter(), is(parseTimestamp("2016-01-08T00:00:00Z")));
|
||||
assertThat(order.getCertificate().getLocation(), is(url("https://example.com/acme/cert/1234")));
|
||||
|
|
|
@ -130,8 +130,8 @@ public class ClientTest {
|
|||
// Get the certificate
|
||||
Certificate certificate = order.getCertificate();
|
||||
|
||||
LOG.info("Success! The certificate for domains " + domains + " has been generated!");
|
||||
LOG.info("Certificate URL: " + certificate.getLocation());
|
||||
LOG.info("Success! The certificate for domains {} has been generated!", domains);
|
||||
LOG.info("Certificate URL: {}", certificate.getLocation());
|
||||
|
||||
// Write a combined file containing the certificate and chain.
|
||||
try (FileWriter fw = new FileWriter(DOMAIN_CHAIN_FILE)) {
|
||||
|
@ -214,7 +214,7 @@ public class ClientTest {
|
|||
.agreeToTermsOfService()
|
||||
.useKeyPair(accountKey)
|
||||
.create(session);
|
||||
LOG.info("Registered a new user, URL: " + account.getLocation());
|
||||
LOG.info("Registered a new user, URL: {}", account.getLocation());
|
||||
|
||||
return account;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class ClientTest {
|
|||
* {@link Authorization} to perform
|
||||
*/
|
||||
private void authorize(Authorization auth) throws AcmeException {
|
||||
LOG.info("Authorization for domain " + auth.getDomain());
|
||||
LOG.info("Authorization for domain {}", auth.getIdentifier().getDomain());
|
||||
|
||||
// The authorization is already valid. No need to process a challenge.
|
||||
if (auth.getStatus() == Status.VALID) {
|
||||
|
@ -281,7 +281,7 @@ public class ClientTest {
|
|||
// All reattempts are used up and there is still no valid authorization?
|
||||
if (challenge.getStatus() != Status.VALID) {
|
||||
throw new AcmeException("Failed to pass the challenge for domain "
|
||||
+ auth.getDomain() + ", ... Giving up.");
|
||||
+ auth.getIdentifier().getDomain() + ", ... Giving up.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,15 +308,20 @@ public class ClientTest {
|
|||
|
||||
// Output the challenge, wait for acknowledge...
|
||||
LOG.info("Please create a file in your web server's base directory.");
|
||||
LOG.info("It must be reachable at: http://" + auth.getDomain() + "/.well-known/acme-challenge/" + challenge.getToken());
|
||||
LOG.info("File name: " + challenge.getToken());
|
||||
LOG.info("Content: " + challenge.getAuthorization());
|
||||
LOG.info("It must be reachable at: http://{}/.well-known/acme-challenge/{}",
|
||||
auth.getIdentifier().getDomain(), challenge.getToken());
|
||||
LOG.info("File name: {}", challenge.getToken());
|
||||
LOG.info("Content: {}", challenge.getAuthorization());
|
||||
LOG.info("The file must not contain any leading or trailing whitespaces or line breaks!");
|
||||
LOG.info("If you're ready, dismiss the dialog...");
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("Please create a file in your web server's base directory.\n\n");
|
||||
message.append("http://").append(auth.getDomain()).append("/.well-known/acme-challenge/").append(challenge.getToken()).append("\n\n");
|
||||
message.append("http://")
|
||||
.append(auth.getIdentifier().getDomain())
|
||||
.append("/.well-known/acme-challenge/")
|
||||
.append(challenge.getToken())
|
||||
.append("\n\n");
|
||||
message.append("Content:\n\n");
|
||||
message.append(challenge.getAuthorization());
|
||||
acceptChallenge(message.toString());
|
||||
|
@ -345,12 +350,16 @@ public class ClientTest {
|
|||
|
||||
// Output the challenge, wait for acknowledge...
|
||||
LOG.info("Please create a TXT record:");
|
||||
LOG.info("_acme-challenge." + auth.getDomain() + ". IN TXT " + challenge.getDigest());
|
||||
LOG.info("_acme-challenge.{}. IN TXT {}",
|
||||
auth.getIdentifier().getDomain(), challenge.getDigest());
|
||||
LOG.info("If you're ready, dismiss the dialog...");
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("Please create a TXT record:\n\n");
|
||||
message.append("_acme-challenge." + auth.getDomain() + ". IN TXT " + challenge.getDigest());
|
||||
message.append("_acme-challenge.")
|
||||
.append(auth.getIdentifier().getDomain())
|
||||
.append(". IN TXT ")
|
||||
.append(challenge.getDigest());
|
||||
acceptChallenge(message.toString());
|
||||
|
||||
return challenge;
|
||||
|
|
|
@ -106,13 +106,18 @@ public class OrderIT extends PebbleITBase {
|
|||
KeyPair challengeKey = createKeyPair();
|
||||
|
||||
X509Certificate cert = CertificateUtils.createTlsAlpn01Certificate(
|
||||
challengeKey, auth.getDomain(), challenge.getAcmeValidation());
|
||||
challengeKey,
|
||||
auth.getIdentifier().getDomain(),
|
||||
challenge.getAcmeValidation());
|
||||
|
||||
client.dnsAddARecord(TEST_DOMAIN, getBammBammHostname());
|
||||
client.tlsAlpnAddCertificate(auth.getDomain(), challengeKey.getPrivate(), cert);
|
||||
client.tlsAlpnAddCertificate(
|
||||
auth.getIdentifier().getDomain(),
|
||||
challengeKey.getPrivate(),
|
||||
cert);
|
||||
|
||||
cleanup(() -> client.dnsRemoveARecord(TEST_DOMAIN));
|
||||
cleanup(() -> client.tlsAlpnRemoveCertificate(auth.getDomain()));
|
||||
cleanup(() -> client.tlsAlpnRemoveCertificate(auth.getIdentifier().getDomain()));
|
||||
|
||||
return challenge;
|
||||
}, OrderIT::standardRevoker);
|
||||
|
@ -175,7 +180,7 @@ public class OrderIT extends PebbleITBase {
|
|||
assertThat(order.getStatus(), is(Status.PENDING));
|
||||
|
||||
for (Authorization auth : order.getAuthorizations()) {
|
||||
assertThat(auth.getDomain(), is(domain));
|
||||
assertThat(auth.getIdentifier().getDomain(), is(domain));
|
||||
assertThat(auth.getStatus(), is(Status.PENDING));
|
||||
|
||||
if (auth.getStatus() == Status.VALID) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class OrderWildcardIT extends PebbleITBase {
|
|||
assertThat(order.getStatus(), is(Status.PENDING));
|
||||
|
||||
for (Authorization auth : order.getAuthorizations()) {
|
||||
assertThat(auth.getDomain(), is(TEST_DOMAIN));
|
||||
assertThat(auth.getIdentifier().getDomain(), is(TEST_DOMAIN));
|
||||
assertThat(auth.getStatus(), is(Status.PENDING));
|
||||
|
||||
if (auth.getStatus() == Status.VALID) {
|
||||
|
|
Loading…
Reference in New Issue