Skip to content

Commit

Permalink
Feature/improvements in mobile simulator page (#110)
Browse files Browse the repository at this point in the history
* Added settlement model selection box to hub console

* Added currency selection in payer app

* Some changes

* Added configurable transfer expiration for payer mobile sim

* Bumped up the version and postponed audits
  • Loading branch information
vijayg10 committed Jul 20, 2021
1 parent ac87b52 commit da44096
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 55 deletions.
2 changes: 1 addition & 1 deletion audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -30114,7 +30114,7 @@
},
"1763|socket.io-client>socket.io-parser": {
"decision": "postpone",
"madeAt": 1626696276268
"madeAt": 1626796239617
}
},
"rules": {},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ml-testing-toolkit-ui",
"version": "13.0.2",
"version": "13.1.0",
"description": "Mojaloop Testing Toolkit Web User Interface",
"main": "index.js",
"repository": {
Expand Down
65 changes: 62 additions & 3 deletions src/services/demos/MobileSimulator/mojaloopNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ class NotificationService {
})
}

notifyPayerGetAccounts = (progress) => {
// Monitoring Logs
this.notificationEventFunction({
category: 'payer',
type: 'accountsUpdate',
data: {
accounts: progress.response.body
}
})
}

notifyPayeeMonitorLog = (log) => {
// Monitoring Logs
this.notificationEventFunction({
Expand Down Expand Up @@ -135,6 +146,26 @@ class NotificationService {

}

notifyGetHubConsoleInitValues = (progress) => {
if (progress.status === 'FINISHED') {
this.notificationEventFunction({
category: 'hubConsole',
type: 'getHubConsoleInitValuesFinished',
data: {
result: progress
}
})
} else if (progress.status === 'TERMINATED') {
this.notificationEventFunction({
category: 'hubConsole',
type: 'getHubConsoleInitValuesTerminated',
data: {
result: progress
}
})
}
}

notifyDFSPValues = (progress) => {
if (progress.status === 'FINISHED') {
this.notificationEventFunction({
Expand Down Expand Up @@ -180,6 +211,17 @@ class NotificationService {
}
}

notifyGetSettlementModels = (progress) => {
if (progress.response.status === 200) {
this.notificationEventFunction({
category: 'hubConsole',
type: 'settlementModelsUpdate',
data: {
settlementModels: progress.response.body
}
})
}
}
notifyGetSettlements = (progress) => {
if (progress.status === 'FINISHED') {
this.notificationEventFunction({
Expand Down Expand Up @@ -242,7 +284,7 @@ class NotificationService {

handleNotificationLog = (log) => {
// console.log(log)

// Handle the outbound progress events
if ( log.internalLogType === 'outboundProgress' ) {
if (log.status === 'FINISHED' || log.status === 'TERMINATED') {
Expand All @@ -253,6 +295,9 @@ class NotificationService {
case 'GET_DFSP_VALUES':
this.notifyDFSPValues(log)
break
case 'GET_HUBCONSOLE_INIT_VALUES':
this.notifyGetHubConsoleInitValues(log)
break
case 'GET_SETTLEMENTS':
this.notifyGetSettlements(log)
break
Expand All @@ -261,6 +306,7 @@ class NotificationService {
break
}
} else {
// By test case name
switch (log.testCaseName) {
case 'PAYER_FSP_PROVISIONING':
case 'PAYEE_FSP_PROVISIONING':
Expand All @@ -278,7 +324,19 @@ class NotificationService {
case 'GET_PARTICIPANTS':
this.notifyGetParticipants(log)
break
case 'GET_SETTLEMENT_MODELS':
this.notifyGetSettlementModels(log)
break
case 'GET_PAYER_ACCOUNTS':
this.notifyPayerGetAccounts(log)
break
}
// By request name
switch (log.requestSent.description) {
case 'GET_PAYER_ACCOUNTS':
this.notifyPayerGetAccounts(log)
break
}
}
return null
}
Expand Down Expand Up @@ -612,7 +670,8 @@ class NotificationService {
category: 'payee',
type: 'payeePutQuotes',
data: {
resource: log.resource
resource: log.resource,
requestBody: log.additionalData.request.body
}
})
}
Expand All @@ -630,7 +689,7 @@ class NotificationService {
type: 'payeePutQuotesResponse',
data: {
resource: log.resource,
responseStatus: log.additionalData.response.status + ' ' + log.additionalData.response.statusText
responseStatus: log.additionalData.response && (log.additionalData.response.status + ' ' + log.additionalData.response.statusText)
}
})
}
Expand Down
29 changes: 27 additions & 2 deletions src/services/demos/MobileSimulator/mojaloopOutbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
import axios from 'axios'
import { getConfig, getServerConfig } from '../../../utils/getConfig'
import { TraceHeaderUtils } from '@mojaloop/ml-testing-toolkit-shared-lib'
import _ from 'lodash';

class OutboundService {

apiBaseUrl = ''
inputValues = {}
sessionId = '123'
userConfig = {}
customParams = {
payerFspTransferExpirationOffset: 60 * 1000
}

constructor (sessionId = '123') {
const { apiBaseUrl } = getConfig()
Expand Down Expand Up @@ -68,6 +72,14 @@ class OutboundService {
}
}

setCustomParams = (newConfig) => {
_.merge(this.customParams, newConfig)
}

getCustomParams = () => {
return this.customParams
}

async getParties (idNumber) {
const traceId = this.getTraceId()
const template = require('./template_getParties.json')
Expand All @@ -81,12 +93,13 @@ class OutboundService {
// return null
return resp
}
async postQuotes (amount) {
async postQuotes (amount, currency) {
const traceId = this.getTraceId()
const template = require('./template_postQuotes.json')
template.inputValues = this.inputValues
// Replace corresponding values in inputValues
template.inputValues.amount = amount + ''
template.inputValues.currency = currency + ''
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
// if(typeof response.data === 'object') {
// return response.data
Expand All @@ -104,6 +117,7 @@ class OutboundService {
template.inputValues.quotesCallbackExpiration = expiration + ''
template.inputValues.quotesCallbackIlpPacket = ilpPacket + ''
template.inputValues.quotesCallbackCondition = condition + ''
template.inputValues.expirationOffset = this.customParams.payerFspTransferExpirationOffset
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
// if(typeof response.data === 'object') {
// return response.data
Expand All @@ -118,6 +132,15 @@ class OutboundService {
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
return resp
}

async getHubConsoleInitValues () {
const traceId = this.getTraceId()
const template = require('./template_getHubConsoleInitValues.json')
template.inputValues = this.inputValues
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
return resp
}

async getDFSPValues () {
const traceId = this.getTraceId()
const template = require('./template_getDFSPValues')
Expand All @@ -134,10 +157,12 @@ class OutboundService {
return resp
}

async executeSettlement () {
async executeSettlement (settlementModel) {
const traceId = this.getTraceId()
const template = require('./template_executeSettlement')
template.inputValues = this.inputValues
// Replace corresponding values in inputValues
template.inputValues.settlementModel = settlementModel + ''
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
return resp
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
},
"scriptingEngine": "javascript",
"body": {
"settlementModel": "DEFERREDNET",
"settlementModel": "{$inputs.settlementModel}",
"reason": "TESTING",
"settlementWindows": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "GET_HUBCONSOLE_INIT_VALUES",
"test_cases": [
{
"id": 1,
"name": "GET_SETTLEMENT_MODELS",
"requests": [
{
"id": 9,
"description": "test",
"apiVersion": {
"minorVersion": 0,
"majorVersion": 1,
"type": "central_admin"
},
"operationPath": "/settlementModels",
"path": "/settlementModels",
"method": "get",
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
"headers": {
"FSPIOP-Source": "{$inputs.fromFspId}"
},
"params": {
"id": ""
}
}
]
}
]
}
16 changes: 16 additions & 0 deletions src/services/demos/MobileSimulator/template_getParties.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@
]
}
}
},
{
"id": 4,
"description": "GET_PAYER_ACCOUNTS",
"apiVersion": {
"minorVersion": 0,
"majorVersion": 1,
"type": "central_admin"
},
"operationPath": "/participants/{name}/accounts",
"path": "/participants/{$inputs.mobileSimPayerFsp}/accounts",
"method": "get",
"params": {
"name": "{$inputs.mobileSimPayerFsp}"
},
"url": "{$inputs.HOST_CENTRAL_LEDGER}"
}
]
}
Expand Down
17 changes: 15 additions & 2 deletions src/services/demos/MobileSimulator/template_postTransfers.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,27 @@
"amount": "{$inputs.amount}",
"currency": "{$inputs.currency}"
},
"expiration": "{$inputs.quotesCallbackExpiration}",
"expiration": "{$requestVariables.transferExpiration}",
"ilpPacket": "{$inputs.quotesCallbackIlpPacket}",
"condition": "{$inputs.quotesCallbackCondition}"
},
"tests": {
"assertions": []
},
"url": "{$inputs.HOST_ML_API_ADAPTER}"
"url": "{$inputs.HOST_ML_API_ADAPTER}",
"scriptingEngine": "javascript",
"scripts": {
"preRequest": {
"exec": [
"let expirationOffset = 60 * 1000",
"if (environment.expirationOffset) {",
" expirationOffset = environment.expirationOffset",
"}",
"requestVariables.transferExpiration = new Date(new Date().getTime() + expirationOffset).toISOString()",
""
]
}
}
}
]
}
Expand Down
Loading

0 comments on commit da44096

Please sign in to comment.