Search in sources :

Example 1 with RequestId

use of com.github.robozonky.api.confirmations.RequestId in project robozonky by RoboZonky.

the class ZonkoidConfirmationProviderTest method properHttpPost.

@Test
void properHttpPost() throws UnsupportedEncodingException {
    final int loanId = 1;
    final RequestId r = new RequestId("user@somewhere.cz", "apitest".toCharArray());
    final HttpPost post = ZonkoidConfirmationProvider.getRequest(r, loanId, 200, "https", "somewhere");
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(post.getFirstHeader("Accept").getValue()).isEqualTo("text/plain");
        softly.assertThat(post.getFirstHeader("Authorization").getValue()).isNotEmpty().isEqualTo(ZonkoidConfirmationProvider.getAuthenticationString(r, loanId));
        softly.assertThat(post.getFirstHeader("Content-Type").getValue()).isEqualTo("application/x-www-form-urlencoded");
        softly.assertThat(post.getEntity()).isInstanceOf(UrlEncodedFormEntity.class);
        softly.assertThat(post.getFirstHeader("User-Agent").getValue()).isEqualTo(Defaults.ROBOZONKY_USER_AGENT);
    });
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) RequestId(com.github.robozonky.api.confirmations.RequestId) Test(org.junit.jupiter.api.Test)

Example 2 with RequestId

use of com.github.robozonky.api.confirmations.RequestId in project robozonky by RoboZonky.

the class ConfirmationProviderLoaderTest method loading.

@Test
void loading() {
    final String id = UUID.randomUUID().toString();
    final ConfirmationProvider cp = new ConfirmationProvider() {

        @Override
        public boolean requestConfirmation(final RequestId auth, final int loanId, final int amount) {
            return false;
        }

        @Override
        public String getId() {
            return id;
        }
    };
    final ConfirmationProviderService cps = strategy -> Optional.of(cp);
    assertThat(ConfirmationProviderLoader.load(id, Collections.singleton(cps))).contains(cp);
}
Also used : ConfirmationProviderService(com.github.robozonky.api.confirmations.ConfirmationProviderService) Test(org.junit.jupiter.api.Test) ConfirmationProviderService(com.github.robozonky.api.confirmations.ConfirmationProviderService) RequestId(com.github.robozonky.api.confirmations.RequestId) Optional(java.util.Optional) Assertions(org.assertj.core.api.Assertions) UUID(java.util.UUID) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Collections(java.util.Collections) RequestId(com.github.robozonky.api.confirmations.RequestId) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Test(org.junit.jupiter.api.Test)

Example 3 with RequestId

use of com.github.robozonky.api.confirmations.RequestId in project robozonky by RoboZonky.

the class ZonkoidConfirmationProviderTest method execute.

private boolean execute(final int code) {
    this.mockServerResponse(code);
    final boolean result = ZonkoidConfirmationProvider.requestConfirmation(new RequestId("user@somewhere.cz", "apitest".toCharArray()), 1, 200, serverUrl);
    this.verifyClientRequest();
    return result;
}
Also used : RequestId(com.github.robozonky.api.confirmations.RequestId)

Aggregations

RequestId (com.github.robozonky.api.confirmations.RequestId)3 Test (org.junit.jupiter.api.Test)2 ConfirmationProvider (com.github.robozonky.api.confirmations.ConfirmationProvider)1 ConfirmationProviderService (com.github.robozonky.api.confirmations.ConfirmationProviderService)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 HttpPost (org.apache.http.client.methods.HttpPost)1 Assertions (org.assertj.core.api.Assertions)1