use of com.ingenico.connect.gateway.sdk.java.Session in project connect-sdk-java by Ingenico-ePayments.
the class SDKProxyTest method assertProxySet.
@SuppressWarnings("resource")
private void assertProxySet(ApiResource resource, ProxyConfiguration proxyConfiguration) {
Communicator communicator = getField(resource, "communicator", Communicator.class);
Session session = getField(communicator, "session", Session.class);
DefaultConnection connection = getField(session, "connection", DefaultConnection.class);
CloseableHttpClient httpClient = getField(connection, "httpClient", CloseableHttpClient.class);
DefaultProxyRoutePlanner routePlanner = getField(httpClient, "routePlanner", DefaultProxyRoutePlanner.class);
HttpHost proxy = getField(routePlanner, "proxy", HttpHost.class);
Assert.assertEquals(proxyConfiguration.getScheme(), proxy.getSchemeName());
Assert.assertEquals(proxyConfiguration.getPort(), proxy.getPort());
BasicCredentialsProvider credentialsProvider = getField(httpClient, "credentialsProvider", BasicCredentialsProvider.class);
AuthScope authScope = new AuthScope(proxy);
Credentials credentials = credentialsProvider.getCredentials(authScope);
Assert.assertTrue(credentials instanceof UsernamePasswordCredentials);
UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;
Assert.assertEquals(proxyConfiguration.getUsername(), usernamePasswordCredentials.getUserName());
Assert.assertEquals(proxyConfiguration.getPassword(), usernamePasswordCredentials.getPassword());
}
use of com.ingenico.connect.gateway.sdk.java.Session in project connect-sdk-java by Ingenico-ePayments.
the class MultiLineHeaderTest method test.
/**
* Smoke test for products service.
*/
@Test
public void test() throws URISyntaxException, IOException {
CommunicatorConfiguration configuration = getCommunicatorConfiguration();
String multiLineHeader = " some value \r\n \n with some \r\n spaces ";
MetaDataProvider metaDataProvider = new MetaDataProviderBuilder("Ingenico").withAdditionalRequestHeader(new RequestHeader("X-GCS-MultiLineHeader", multiLineHeader)).build();
DirectoryParams params = new DirectoryParams();
params.setCountryCode("NL");
params.setCurrencyCode("EUR");
Session session = Factory.createSessionBuilder(configuration).withMetaDataProvider(metaDataProvider).build();
Client client = Factory.createClient(session);
try {
Directory response = client.merchant("8500").products().directory(809, params);
Assert.assertTrue(response.getEntries().size() > 0);
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.Session in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method createClient.
@SuppressWarnings("resource")
private Client createClient(HttpHost host, int connectTimeout, int socketTimeout) throws URISyntaxException {
URI uri = new URI(host.getSchemeName(), null, host.getHostName(), host.getPort(), null, null, null);
Connection connection = new DefaultConnection(connectTimeout, socketTimeout);
Authenticator authenticator = new DefaultAuthenticator(AuthorizationType.V1HMAC, "apiKey", "secret");
MetaDataProvider metaDataProvider = new MetaDataProvider("Ingenico");
Session session = new Session(uri, connection, authenticator, metaDataProvider);
Communicator communicator = Factory.createCommunicator(session);
Client client = Factory.createClient(communicator);
return client;
}
use of com.ingenico.connect.gateway.sdk.java.Session in project connect-sdk-java by Ingenico-ePayments.
the class PaymentsClientTest method initializeSession.
@Before
public void initializeSession() {
URI apiEndpoint = URI.create("http://localhost");
session = new Session(apiEndpoint, connection, new DefaultAuthenticator(AuthorizationType.V1HMAC, "test", "test"), new MetaDataProvider("Ingenico"));
}
use of com.ingenico.connect.gateway.sdk.java.Session in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionIdempotenceTest method createClient.
@SuppressWarnings("resource")
private Client createClient(HttpHost host) {
Connection connection = new DefaultConnection(500, 500);
Authenticator authenticator = new DefaultAuthenticator(AuthorizationType.V1HMAC, "apiKey", "secret");
MetaDataProvider metaDataProvider = new MetaDataProvider("Ingenico");
Session session = new Session(URI.create(host.toURI()), connection, authenticator, metaDataProvider);
Communicator communicator = Factory.createCommunicator(session);
Client client = Factory.createClient(communicator);
return client;
}
Aggregations