Search in sources :

Example 1 with DefaultAuthenticator

use of com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator 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"));
}
Also used : MetaDataProvider(com.ingenico.connect.gateway.sdk.java.MetaDataProvider) DefaultAuthenticator(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator) URI(java.net.URI) Session(com.ingenico.connect.gateway.sdk.java.Session) Before(org.junit.Before)

Example 2 with DefaultAuthenticator

use of com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator in project connect-sdk-java by Ingenico-ePayments.

the class FactoryTest method testCreateCommunicator.

@Test
public void testCreateCommunicator() {
    @SuppressWarnings("resource") Communicator communicator = Factory.createCommunicator(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY);
    Assert.assertSame(DefaultMarshaller.INSTANCE, communicator.getMarshaller());
    Session session = ReflectionUtil.getField(communicator, "session", Session.class);
    @SuppressWarnings("resource") Connection connection = session.getConnection();
    Assert.assertTrue(connection instanceof DefaultConnection);
    DefaultConnectionTest.assertConnection((DefaultConnection) connection, -1, -1, 100, null);
    Authenticator authenticator = session.getAuthenticator();
    Assert.assertTrue(authenticator instanceof DefaultAuthenticator);
    Assert.assertEquals(AuthorizationType.V1HMAC, ReflectionUtil.getField(authenticator, "authorizationType", AuthorizationType.class));
    Assert.assertEquals(API_KEY_ID, ReflectionUtil.getField(authenticator, "apiKeyId", String.class));
    Assert.assertEquals(SECRET_API_KEY, ReflectionUtil.getField(authenticator, "secretApiKey", String.class));
    MetaDataProvider metaDataProvider = session.getMetaDataProvider();
    Assert.assertEquals(MetaDataProvider.class, metaDataProvider.getClass());
    Collection<RequestHeader> requestHeaders = metaDataProvider.getServerMetaDataHeaders();
    Assert.assertEquals(1, requestHeaders.size());
    RequestHeader requestHeader = requestHeaders.iterator().next();
    Assert.assertEquals("X-GCS-ServerMetaInfo", requestHeader.getName());
}
Also used : DefaultConnection(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnection) DefaultConnection(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnection) DefaultAuthenticator(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator) AuthorizationType(com.ingenico.connect.gateway.sdk.java.defaultimpl.AuthorizationType) DefaultAuthenticator(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator) DefaultConnectionTest(com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnectionTest) Test(org.junit.Test)

Aggregations

DefaultAuthenticator (com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator)2 MetaDataProvider (com.ingenico.connect.gateway.sdk.java.MetaDataProvider)1 Session (com.ingenico.connect.gateway.sdk.java.Session)1 AuthorizationType (com.ingenico.connect.gateway.sdk.java.defaultimpl.AuthorizationType)1 DefaultConnection (com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnection)1 DefaultConnectionTest (com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnectionTest)1 URI (java.net.URI)1 Before (org.junit.Before)1 Test (org.junit.Test)1