mirror of https://github.com/shred/acme4j
Use returned Registration object after creation
parent
b40861c66c
commit
4fe4c12c62
|
@ -154,8 +154,7 @@ public class Registration extends AcmeResource {
|
|||
conn.sendSignedRequest(getLocation(), claims, getSession());
|
||||
conn.accept(HttpURLConnection.HTTP_CREATED, HttpURLConnection.HTTP_ACCEPTED);
|
||||
|
||||
JSON json = conn.readJsonResponse();
|
||||
unmarshal(json, conn);
|
||||
unmarshal(conn.readJsonResponse());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,10 +342,8 @@ public class Registration extends AcmeResource {
|
|||
*
|
||||
* @param json
|
||||
* JSON data
|
||||
* @param conn
|
||||
* {@link Connection} with headers to be evaluated
|
||||
*/
|
||||
private void unmarshal(JSON json, Connection conn) {
|
||||
protected void unmarshal(JSON json) {
|
||||
if (json.contains(KEY_TOS_AGREED)) {
|
||||
this.termsOfServiceAgreed = json.get(KEY_TOS_AGREED).asBoolean();
|
||||
}
|
||||
|
@ -365,11 +362,6 @@ public class Registration extends AcmeResource {
|
|||
this.status = Status.parse(json.get(KEY_STATUS).asString());
|
||||
}
|
||||
|
||||
URL location = conn.getLocation();
|
||||
if (location != null) {
|
||||
setLocation(location);
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
|
@ -442,7 +434,7 @@ public class Registration extends AcmeResource {
|
|||
conn.accept(HttpURLConnection.HTTP_ACCEPTED);
|
||||
|
||||
JSON json = conn.readJsonResponse();
|
||||
unmarshal(json, conn);
|
||||
unmarshal(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,11 +103,13 @@ public class RegistrationBuilder {
|
|||
}
|
||||
|
||||
conn.sendJwkSignedRequest(session.resourceUrl(Resource.NEW_REG), claims, session);
|
||||
conn.accept(HttpURLConnection.HTTP_CREATED);
|
||||
conn.accept(HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED);
|
||||
|
||||
URL location = conn.getLocation();
|
||||
|
||||
return new Registration(session, location);
|
||||
Registration reg = new Registration(session, location);
|
||||
reg.unmarshal(conn.readJsonResponse());
|
||||
return reg;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class RegistrationBuilderTest {
|
|||
assertThat(httpStatus, isIntArrayContainingInAnyOrder(HttpURLConnection.HTTP_CREATED, HttpURLConnection.HTTP_ACCEPTED));
|
||||
return HttpURLConnection.HTTP_ACCEPTED;
|
||||
} else {
|
||||
assertThat(httpStatus, isIntArrayContainingInAnyOrder(HttpURLConnection.HTTP_CREATED));
|
||||
assertThat(httpStatus, isIntArrayContainingInAnyOrder(HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED));
|
||||
return HttpURLConnection.HTTP_CREATED;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ public class RegistrationBuilderTest {
|
|||
|
||||
@Override
|
||||
public JSON readJsonResponse() {
|
||||
assertThat(isUpdate, is(true));
|
||||
return getJsonAsObject("newRegistrationResponse");
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue