From 4e1ad652b05232af83f99978801f8ae25ffa25a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Tue, 2 May 2017 14:27:07 +0200 Subject: [PATCH] Account deactivation returns HTTP_OK and current account data --- .../main/java/org/shredzone/acme4j/Registration.java | 4 +++- .../java/org/shredzone/acme4j/RegistrationTest.java | 12 +++++++++--- .../json/deactivateRegistrationResponse.json | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 acme4j-client/src/test/resources/json/deactivateRegistrationResponse.json diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java index 6c7f1e4a..67ef8c2a 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java @@ -269,7 +269,9 @@ public class Registration extends AcmeResource { claims.put(KEY_STATUS, "deactivated"); conn.sendSignedRequest(getLocation(), claims, getSession()); - conn.accept(HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_ACCEPTED); + conn.accept(HttpURLConnection.HTTP_OK); + + unmarshal(conn.readJsonResponse()); } } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java index 1d4c9493..1bcdf26e 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java @@ -433,15 +433,21 @@ public class RegistrationTest { @Override public int accept(int... httpStatus) throws AcmeException { - assertThat(httpStatus, isIntArrayContainingInAnyOrder( - HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_ACCEPTED)); - return HttpURLConnection.HTTP_ACCEPTED; + assertThat(httpStatus, isIntArrayContainingInAnyOrder(HttpURLConnection.HTTP_OK)); + return HttpURLConnection.HTTP_OK; + } + + @Override + public JSON readJsonResponse() { + return getJSON("deactivateRegistrationResponse"); } }; Registration registration = new Registration(provider.createSession(), locationUrl); registration.deactivate(); + assertThat(registration.getStatus(), is(Status.DEACTIVATED)); + provider.close(); } diff --git a/acme4j-client/src/test/resources/json/deactivateRegistrationResponse.json b/acme4j-client/src/test/resources/json/deactivateRegistrationResponse.json new file mode 100644 index 00000000..4ac6d479 --- /dev/null +++ b/acme4j-client/src/test/resources/json/deactivateRegistrationResponse.json @@ -0,0 +1,3 @@ +{ + "status": "deactivated" +}