Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #22

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

test #22

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
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ jobs:
IMAGE_TAG=$CIRCLE_TAG

# Check if the Docker image with the same tag already exists in Docker Hub
if curl -s -f -u "$DOCKERHUB_USERNAME":"$DOCKERHUB_PASSWORD" "https://hub.docker.com/v2/repositories/openmf/ph-ee-connector-mojaloop/tags/$IMAGE_TAG" > /dev/null; then
if curl -s -f -u "$DOCKERHUB_USERNAME":"$DOCKERHUB_PASSWORD" "https://hub.docker.com/v2/repositories/fynarfin/ph-ee-connector-mojaloop/tags/$IMAGE_TAG" > /dev/null; then
echo "Skipping the build and push as the tag $IMAGE_TAG already exists in Docker Hub."
exit 0
fi

# Build and tag the Docker image
./gradlew bootJar
docker build -t "openmf/ph-ee-connector-mojaloop:$IMAGE_TAG" .
docker build -t "fynarfin/ph-ee-connector-mojaloop:$IMAGE_TAG" .

# Push the Docker image to Docker Hub
docker login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_PASSWORD"
docker push "openmf/ph-ee-connector-mojaloop:$IMAGE_TAG"
docker push "fynarfin/ph-ee-connector-mojaloop:$IMAGE_TAG"

# when: always # The job will be executed even if there's no match for the tag filter

Expand All @@ -55,13 +55,13 @@ jobs:
name: Build Docker image
command: |
./gradlew bootJar
docker build -t openmf/ph-ee-connector-mojaloop:latest .
if [ "$CIRCLE_BRANCH" != "master" ]; then
docker build -t fynarfin/ph-ee-connector-mojaloop:latest .
if [ "$CIRCLE_BRANCH" != "develop" ]; then
PR_NUMBER=$(basename $CIRCLE_PULL_REQUEST)
PR_TITLE=$(curl -sSL "https://api.github.com/repos/openmf/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title')
PR_TITLE=$(curl -sSL "https://api.github.com/repos/fynarfin/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title')
JIRA_STORY=$(echo $PR_TITLE | cut -d "[" -f2 | cut -d "]" -f1 | tr '[A-Z]' '[a-z]')
if [ -z "$JIRA_STORY" ]; then echo "Invalid PR title" && exit 1; else echo "Ticket NO: $JIRA_STORY"; fi
docker image tag openmf/ph-ee-connector-mojaloop:latest openmf/ph-ee-connector-mojaloop:$JIRA_STORY
docker image tag fynarfin/ph-ee-connector-mojaloop:latest fynarfin/ph-ee-connector-mojaloop:$JIRA_STORY
fi

# Log in to DockerHub using environment variables
Expand All @@ -73,14 +73,14 @@ jobs:
- run:
name: Push Docker image to DockerHub
command: |
if [ "$CIRCLE_BRANCH" = "master" ]; then
docker push openmf/ph-ee-connector-mojaloop:latest
if [ "$CIRCLE_BRANCH" = "develop" ]; then
docker push fynarfin/ph-ee-connector-mojaloop:latest
fi
if [ "$CIRCLE_BRANCH" != "master" ]; then
if [ "$CIRCLE_BRANCH" != "develop" ]; then
PR_NUMBER=$(basename $CIRCLE_PULL_REQUEST)
PR_TITLE=$(curl -sSL "https://api.github.com/repos/openmf/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title')
PR_TITLE=$(curl -sSL "https://api.github.com/repos/fynarfin/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title')
JIRA_STORY=$(echo $PR_TITLE | cut -d "[" -f2 | cut -d "]" -f1 | tr '[A-Z]' '[a-z]')
docker push openmf/ph-ee-connector-mojaloop:${JIRA_STORY}
docker push fynarfin/ph-ee-connector-mojaloop:${JIRA_STORY}
fi

workflows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void configure() {
Class type = (Class) exchange.getProperty(CLASS_TYPE);
String bdy = exchange.getIn().getBody(String.class);
exchange.getIn().setBody(objectMapper.readValue(bdy, type));
logger.debug("Converted dto: {}", exchange.getIn().getBody());
logger.info("Converted dto: {}", exchange.getIn().getBody());
} catch (Exception e) {
logger.error("Error while unmarshling body: {}", e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class GetCachedTransactionIdProcessor implements Processor {
public void process(Exchange exchange) {
String transactionIdKey = null;
String traceparent = exchange.getIn().getHeader(HEADER_TRACEPARENT, String.class);
logger.debug("trace parent header: {}", traceparent);
logger.info("trace parent header: {}", traceparent);

String transactionId = resolveTransactionIdFromTraceparent(traceparent);

logger.debug("resolved parent {} to transactionId {}", traceparent, transactionId);
logger.info("resolved parent {} to transactionId {}", traceparent, transactionId);
exchange.setProperty(CamelProperties.CACHED_TRANSACTION_ID, transactionId);

if (transactionId == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,24 @@ public void configure() {
.otherwise()
.process(e -> {
String host = e.getIn().getHeader("Host", String.class).split(":")[0];
log.debug("HOST: {}", host);
String tenantId = partyProperties.getPartyByDomain(host).getTenantId();
log.debug("TENANT ID: {}", tenantId);
log.debug("Headers: {}", e.getIn().getHeaders());
log.info("HOST: {}", host);
String payeeFsp = e.getIn().getHeader(FSPIOP_DESTINATION.headerName(), String.class);
log.debug("Payeefsp: {}", payeeFsp);
log.debug("PARTIES: {}", objectMapper.writeValueAsString(partyProperties.getParties()));
log.debug("PAYEE TENANT: {}", partyProperties.getPartyByDfsp(payeeFsp).getTenantId());
log.info("FSPIOP DESTINATION: {}", payeeFsp);
String tenantId = partyProperties.getPartyByDomain(host, payeeFsp).getTenantId();

log.info("Tenant ID: {}", tenantId);
log.info("Headers: {}", e.getIn().getHeaders());
log.info("Payeefsp: {}", payeeFsp);
log.info("PARTIES: {}", objectMapper.writeValueAsString(partyProperties.getParties()));
log.info("PAYEE TENANT: {}", partyProperties.getPartyByDfsp(payeeFsp).getTenantId());
zeebeProcessStarter.startZeebeWorkflow(partyLookupFlow.replace("{tenant}", tenantId),
variables -> {
variables.put(HEADER_DATE, e.getIn().getHeader(HEADER_DATE));
variables.put(HEADER_TRACEPARENT, e.getIn().getHeader(HEADER_TRACEPARENT));
variables.put(FSPIOP_SOURCE.headerName(), e.getIn().getHeader(FSPIOP_SOURCE.headerName()));
log.info("FSPIOP_SOURCE.headerName() {}", variables.get(FSPIOP_SOURCE.headerName()));
variables.put(PAYEE_TENANT_ID, partyProperties.getPartyByDfsp(payeeFsp).getTenantId());
log.info("PAYEE_TENANT_ID {}", partyProperties.getPartyByDfsp(payeeFsp).getTenantId());
variables.put(PARTY_ID_TYPE, e.getIn().getHeader(PARTY_ID_TYPE));
variables.put(PARTY_ID, e.getIn().getHeader(PARTY_ID));
variables.put(TENANT_ID, tenantId);
Expand Down Expand Up @@ -141,7 +145,7 @@ public void configure() {
new PartyIdInfo(IdentifierType.valueOf(e.getIn().getHeader(PARTY_ID_TYPE, String.class)),
e.getIn().getHeader(PARTY_ID, String.class),
null,
partyProperties.getPartyByDomain(host).getFspId()),
partyProperties.getPartyByDomain(host, null).getFspId()),
null,
null,
null);
Expand Down Expand Up @@ -186,13 +190,17 @@ public void configure() {
PartyIdInfo requestedParty = e.getProperty(IS_RTP_REQUEST, Boolean.class) ? channelRequest.getPayer().getPartyIdInfo() : channelRequest.getPayee().getPartyIdInfo();
e.setProperty(PARTY_ID_TYPE, requestedParty.getPartyIdType());
e.setProperty(PARTY_ID, requestedParty.getPartyIdentifier());
e.setProperty(PAYEE_DFSP_ID, e.getProperty(PAYEE_DFSP_ID, String.class));
log.info("PAYEE_DFSP_ID {}", e.getProperty(PAYEE_DFSP_ID, String.class));
if(e.getProperty(PAYEE_DFSP_ID, String.class) != null) {
e.getIn().setHeader(FSPIOP_DESTINATION.headerName(), e.getProperty(PAYEE_DFSP_ID, String.class));
}
e.getIn().setHeader(FSPIOP_SOURCE.headerName(), partyProperties.getPartyByTenant(e.getProperty(TENANT_ID, String.class)).getFspId());

mojaloopUtil.setPartyHeadersRequest(e);
})
.process(addTraceHeaderProcessor)
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.process(e -> log.info("Mojaloop headers : {}", e.getIn().getHeaders()))
.process(e -> log.info("Mojaloop send-party-lookup headers : {}", e.getIn().getHeaders()))
.setProperty(HOST, simple("{{switch.als-host}}"))
.setProperty(ENDPOINT, simple("/parties/${exchangeProperty." + PARTY_ID_TYPE + "}/${exchangeProperty." + PARTY_ID + "}"))
.to("direct:external-api-call")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,7 @@
import static org.mifos.connector.common.mojaloop.type.MojaloopHeaders.FSPIOP_SOURCE;
import static org.mifos.connector.mojaloop.camel.config.CamelProperties.*;
import static org.mifos.connector.mojaloop.zeebe.ZeebeProcessStarter.zeebeVariablesToCamelHeaders;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.ACCOUNT_CURRENCY;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.CHANNEL_REQUEST;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.ERROR_INFORMATION;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.INITIATOR_FSP_ID;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.IS_RTP_REQUEST;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.ORIGIN_DATE;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.PARTY_ID;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.PARTY_ID_TYPE;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.PARTY_LOOKUP_RETRY_COUNT;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.PAYEE_PARTY_RESPONSE;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.TENANT_ID;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.TRANSACTION_ID;
import static org.mifos.connector.mojaloop.zeebe.ZeebeVariables.*;
import static org.mifos.connector.mojaloop.zeebe.ZeebeeWorkers.WORKER_PARTY_LOOKUP_LOCAL_RESPONSE;
import static org.mifos.connector.mojaloop.zeebe.ZeebeeWorkers.WORKER_PARTY_LOOKUP_REQUEST;
import static org.mifos.connector.mojaloop.zeebe.ZeebeeWorkers.WORKER_PARTY_REGISTRATION_ORACLE;
Expand Down Expand Up @@ -82,6 +71,8 @@ public void setupWorkers() {

boolean isTransactionRequest = (boolean) existingVariables.get(IS_RTP_REQUEST);
String tenantId = (String) existingVariables.get(TENANT_ID);
String payeeFspId = (String) existingVariables.get(PAYEE_DFSP_ID);
logger.info("Payee fsp id is {}", payeeFspId);
Object channelRequest = existingVariables.get(CHANNEL_REQUEST);
// only saved for operations to identify workflow
if (existingVariables.get(INITIATOR_FSP_ID) == null) {
Expand All @@ -98,6 +89,7 @@ public void setupWorkers() {
exchange.setProperty(ORIGIN_DATE, existingVariables.get(ORIGIN_DATE));
exchange.setProperty(IS_RTP_REQUEST, isTransactionRequest);
exchange.setProperty(TENANT_ID, tenantId);
exchange.setProperty(PAYEE_DFSP_ID, payeeFspId);
producerTemplate.send("direct:send-party-lookup", exchange);
} else {
PartyIdInfo partyIdInfo = new PartyIdInfo(MSISDN, "27710305999", null, "in03tn05");
Expand Down Expand Up @@ -139,8 +131,8 @@ public void setupWorkers() {
exchange.setProperty(PARTY_ID_TYPE, existingVariables.get(PARTY_ID_TYPE));
exchange.setProperty(PARTY_ID, existingVariables.get(PARTY_ID));

logger.debug("Error info: {}", objectMapper.writeValueAsString(errorInformation));
logger.debug("Zeebe variables: {}", existingVariables);
logger.info("Error info: {}", objectMapper.writeValueAsString(errorInformation));
logger.info("Zeebe variables: {}", existingVariables);
producerTemplate.send("direct:send-parties-error-response", exchange);
} else {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package org.mifos.connector.mojaloop.properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Component
@ConfigurationProperties
public class PartyProperties {

private static final Logger log = LoggerFactory.getLogger(PartyProperties.class);
private List<Party> parties = new ArrayList<>();

public PartyProperties() {
Expand Down Expand Up @@ -37,10 +41,20 @@ public Party getPartyByTenant(String tenant) {
.orElseThrow(() -> new RuntimeException("Party with tenant: " + tenant + ", not configured!"));
}

public Party getPartyByDomain(String domain) {
return getParties().stream()
public Party getPartyByDomain(String domain, String payeeFsp) {
List<Party> filteredParties = getParties().stream()
.filter(t -> t.getDomain().equals(domain))
.toList();
log.info("Filtered party: " + filteredParties.toString());
if (payeeFsp == null || payeeFsp.isEmpty() || filteredParties.size() == 1) {
return filteredParties.stream()
.findFirst()
.orElseThrow(() -> new RuntimeException("Party with domain: " + domain + ", not configured!"));
}

return filteredParties.stream()
.filter(t -> t.getFspId().equals(payeeFsp))
.findFirst()
.orElseThrow(() -> new RuntimeException("Party with domain: " + domain + ", not configured!"));
.orElseThrow(() -> new RuntimeException("Party with domain: " + domain + " and payeeFsp: " + payeeFsp + ", not configured!"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void process(Exchange exchange) throws JsonProcessingException {
variables.put(QUOTE_FAILED, true);
} else {
QuoteCallbackDTO response = exchange.getIn().getBody(QuoteCallbackDTO.class);
logger.debug("ILP PACKET: {}", response.getIlpPacket());
logger.debug("CONDITION: {}", response.getCondition());
logger.info("ILP PACKET: {}", response.getIlpPacket());
logger.info("CONDITION: {}", response.getCondition());
messageName = QUOTE_CALLBACK;
variables.put(PAYEE_QUOTE_RESPONSE, objectMapper.writeValueAsString(response));
if (isMojaloopEnabled && !ilpBuilder.isValidPacketAgainstCondition(response.getIlpPacket(), response.getCondition())) {
Expand Down
Loading