Login { public Challenge bindChallenge(URL location) { try { Connection connect = session.connect(); connect.sendSignedPostAsGetRequest(location, this); return createChallenge(connect.readJsonResponse()); } catch (AcmeException ex) { throw new AcmeLazyLoadingException(Challenge.class, location, ex); } } Login(URL accountLocation, KeyPair keyPair, Session session); Session getSession(); KeyPair getKeyPair(); URL getAccountLocation(); Account getAccount(); Authorization bindAuthorization(URL location); Certificate bindCertificate(URL location); Order bindOrder(URL location); Challenge bindChallenge(URL location); Challenge createChallenge(JSON data);  }
@Test public void testBindChallenge() throws Exception { URL locationUrl = new URL("https: Http01Challenge mockChallenge = mock(Http01Challenge.class); JSON httpChallenge = getJSON("httpChallenge"); TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public int sendSignedPostAsGetRequest(URL url, Login login) { assertThat(url, is(locationUrl)); return HttpURLConnection.HTTP_OK; } @Override public JSON readJsonResponse() { return httpChallenge; } @Override public Challenge createChallenge(Login login, JSON json) { assertThat(json, is(httpChallenge)); return mockChallenge; } }; Login login = provider.createLogin(); Challenge challenge = login.bindChallenge(locationUrl); assertThat(challenge, is(instanceOf(Http01Challenge.class))); assertThat(challenge, is(sameInstance(mockChallenge))); }