Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/app/scheme-adapter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<set-session-variable variableName="payeeUrl" value="#[payload.payee.url]"
doc:name="Save Input Receiver URL" />
<json:object-to-json-transformer doc:name="Object to JSON" />
<set-property propertyName="initiator" value="PROXY"></set-property>
<set-property propertyName="initiator" value="PROXY" doc:name="Property"></set-property>
<logger level="INFO"
message="Posting request to payee scheme-adapter /quotes to http://#[sessionVars.payeeUrl]/quotes, method=POST, Payload: #[payload]"
category="com.l1p.interop.scheme.adapter.quote" doc:name="logger" />
Expand Down Expand Up @@ -218,7 +218,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
expression="#[sessionVars.originalQuoteRequestMap.get(&quot;amount&quot;).put(&quot;amount&quot;,sessionVars.destinationAmount); sessionVars.originalQuoteRequestMap]"
doc:name="Update dfsp request with destination amount from ilp-service /quoteSourceAmount" />
<json:object-to-json-transformer doc:name="Object to JSON" />
<set-property propertyName="initiator" value="PROXY"></set-property>
<set-property propertyName="initiator" value="PROXY" doc:name="Property"></set-property>
<logger level="INFO"
message="Posting request to scheme-adapter /quotes http://#[sessionVars.payeeUrl]/quotes, method=POST Payload: #[payload]"
category="com.l1p.interop.scheme.adapter.quote" doc:name="logger" />
Expand Down Expand Up @@ -302,6 +302,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<object-to-string-transformer doc:name="Object to String" />
</flow>
<flow name="post:/notifications:application/json:scheme-adapter-config">
<logger message="Posting ILP Service request for L1p-Trace-Id=#[sessionVars.'L1p-Trace-Id'] to http://${ilp-host}:${ilp-service.port}/notifications, method=POST Payload: #[payload]" level="INFO" category="com.l1p.interop.scheme.adapter.quote" doc:name="logger"/>
<set-payload value="#[NullPayload.getInstance()]" doc:name="Set Payload" />
</flow>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package com.l1p.interop.scheme.adapter;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
Expand All @@ -8,17 +17,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;

import io.restassured.response.Response;
import static io.restassured.RestAssured.given;
import static org.junit.Assert.assertEquals;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.hamcrest.CoreMatchers.equalTo;

public class TestSchemeAdapter extends FunctionalTestCase {

protected Logger logger = LoggerFactory.getLogger(getClass());
private static WireMockServer wireMockServer;

@Rule
public WireMockRule mockReceiverSchemeAdapter = new WireMockRule(8090);
Expand All @@ -31,6 +38,9 @@ public class TestSchemeAdapter extends FunctionalTestCase {

@Rule
public WireMockRule ilpService = new WireMockRule(3045);

@Rule
public WireMockRule notificationsService = new WireMockRule(8088);


@Override
Expand Down Expand Up @@ -59,7 +69,7 @@ public void testQuery() throws Exception {
body("name", equalTo("alice")).
body("balance", equalTo("1000.00")).
body("currencyCode", equalTo("USD")).
body("currencySymbol", equalTo("$")).
body("currencySymbol", equalTo("$")).
body("is_disabled", equalTo(false)).
body("ledger", equalTo("http://ec2-35-166-180-190.us-west-2.compute.amazonaws.com:8088/ilp/ledger/v1"));

Expand Down Expand Up @@ -116,9 +126,81 @@ public void testQuotes() throws Exception {
assertEquals("expiresAt","2017-06-14T00:00:01.000Z",(String)response.jsonPath().get("expiresAt"));
}


@Test
@Ignore
public void testPayments() throws Exception {

String proxyPaymentRequestJson = loadResourceAsString("test_data/proxyPaymentRequest.json");
String paymentMockResponseJson = loadResourceAsString("test_data/paymentMockResponse.json");

ilpService.stubFor(post(urlMatching("/payIPR")).willReturn(aResponse().withBody(paymentMockResponseJson).withStatus(201)).atPriority(2));

Response response =
given().
contentType("application/json").
body(proxyPaymentRequestJson).
when().
post("http://localhost:8088/scheme/adapter/v1/payments");

logger.info("Response: "+response.asString());

assertEquals("paymentId","123456",(String)response.jsonPath().get("paymentId"));
assertEquals("connectorAccount","123456",(String)response.jsonPath().get("connectorAccount"));
assertEquals("status","1",(String)response.jsonPath().get("status"));
assertEquals("rejectionMessage","rejection message",(String)response.jsonPath().get("rejectionMessage"));
assertEquals("fulfillment","fulfillment",(String)response.jsonPath().get("fulfillment"));

}


@Test
public void testIlpAddress() throws Exception {

String ilpAddressResponseJson = loadResourceAsString("test_data/ilpAddressMockResponse.json");
ilpService.stubFor(get(urlMatching("/ilpAddress.*")).willReturn(aResponse().withBody(ilpAddressResponseJson).withStatus(200)));

given().
contentType("application/json").
queryParam("account", "123459").
when().
get("http://localhost:8088/scheme/adapter/v1/ilpAddress").
then().
statusCode(200).
body("ilpAddress", equalTo("ok"));

}


@Test
public void testNotifications() throws Exception {

String notificationRequestBodyJson = loadResourceAsString("test_data/notificationMockRequestBody.json");
notificationsService.stubFor(post(urlPathMatching("/scheme/adapter/v1/notificationsXXX")).willReturn(aResponse().withStatus(500)));

given().
contentType("application/json").
body(notificationRequestBodyJson).
when().
post("http://localhost:8088/scheme/adapter/v1/notifications").
then().
statusCode(200);

}


@Test
public void testHealth() throws Exception {

String healthMockResponseJson = loadResourceAsString("test_data/healthMockResponse.json");
dfspAPIService.stubFor(get(urlPathMatching("/health")).willReturn(aResponse().withBody(healthMockResponseJson)));

given().
contentType("application/json").
when().
get("http://localhost:8088/scheme/adapter/v1/health").
then().
statusCode(200).
body("status", equalTo("ok"));

}

Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/test_data/healthMockResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"status" : "ok"
}
3 changes: 3 additions & 0 deletions src/test/resources/test_data/ilpAddressMockResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ilpAddress" : "ok"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "ipr": "some ipr string","paymentId":"string","destinationAccount":"string","status":"prepared","fulfillment":"string" }
7 changes: 7 additions & 0 deletions src/test/resources/test_data/paymentMockResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"paymentId" : "123456",
"connectorAccount" : "123456",
"status" : "1",
"rejectionMessage" : "rejection message",
"fulfillment" : "fulfillment"
}
7 changes: 7 additions & 0 deletions src/test/resources/test_data/proxyPaymentRequest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ipr" : "123456",
"sourceAmount" : "123.12",
"sourceAccount" : "123456",
"connectorAccount" : "123456",
"sourceExpiryDuration" : "30"
}