Skip to content

Commit

Permalink
fix(mojaloop/3388): parameterized hardcoded currency in thirdparty te…
Browse files Browse the repository at this point in the history
…sts (#124)

* fix: parameterized hardcoded currency in thirdparty tests

* fix: hardcoded currencies

* fix: tp tests
  • Loading branch information
vijayg10 authored Jun 20, 2023
1 parent a29c4c3 commit 3fcd3c3
Showing 1 changed file with 135 additions and 85 deletions.
220 changes: 135 additions & 85 deletions collections/hub/thirdparty/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,24 @@
"assertions": [
{
"id": 1,
"description": "expected response",
"description": "Response body should contain accounts",
"exec": [
"const expected = {",
" accounts: [",
" {",
" accountNickname: 'dfspa.user.nickname1',",
" address: 'dfspa.username.1234',",
" currency: 'ZAR'",
" },",
" {",
" accountNickname: 'dfspa.user.nickname2',",
" address: 'dfspa.username.5678',",
" currency: 'USD'",
" }",
"],",
" currentState: 'COMPLETED'",
"}",
"",
"expect(response.body).to.deep.equal(expected)"
"expect(response.body).to.have.property('accounts')"
]
},
{
"id": 2,
"description": "Accounts array has two elements",
"exec": [
"expect(response.body.accounts).to.have.length(2)"
]
},
{
"id": 3,
"description": "An account should contain addresses",
"exec": [
"expect(response.body.accounts.map(a => a.address)).to.include.members(['dfspa.username.1234', 'dfspa.username.5678']);",
""
]
}
]
Expand Down Expand Up @@ -118,10 +117,21 @@
"OTP"
],
"accounts": [
{ "accountNickname": "XXXXXXnt", "address": "dfspa.username.1234", "currency": "ZAR" },
{ "accountNickname": "SpeXXXXXXXXnt", "address": "dfspa.username.5678", "currency": "USD" }
{
"accountNickname": "XXXXXXnt",
"address": "dfspa.username.1234",
"currency": "{$inputs.currency2}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "dfspa.username.5678",
"currency": "{$inputs.currency}"
}
],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"callbackUri": "pisp-app://callback.com"
},
"url": "{$inputs.PISP_THIRDPARTY_SDK_OUTBOUND_URL}",
Expand Down Expand Up @@ -284,10 +294,21 @@
"OTP"
],
"accounts": [
{ "accountNickname": "XXXXXXnt", "address": "dfspa.username.1234", "currency": "ZAR" },
{ "accountNickname": "SpeXXXXXXXXnt", "address": "dfspa.username.5678", "currency": "USD" }
{
"accountNickname": "XXXXXXnt",
"address": "dfspa.username.1234",
"currency": "{$inputs.currency2}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "dfspa.username.5678",
"currency": "{$inputs.currency}"
}
],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"callbackUri": "pisp-app://callback.com"
},
"url": "{$inputs.PISP_THIRDPARTY_SDK_OUTBOUND_URL}",
Expand Down Expand Up @@ -449,10 +470,21 @@
"OTP"
],
"accounts": [
{ "accountNickname": "XXXXXXnt", "address": "dfspa.username.1234", "currency": "ZAR" },
{ "accountNickname": "SpeXXXXXXXXnt", "address": "dfspa.username.5678", "currency": "USD" }
{
"accountNickname": "XXXXXXnt",
"address": "dfspa.username.1234",
"currency": "{$inputs.currency2}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "dfspa.username.5678",
"currency": "{$inputs.currency}"
}
],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"callbackUri": "pisp-app://callback.com"
},
"tests": {
Expand Down Expand Up @@ -505,10 +537,21 @@
"OTP"
],
"accounts": [
{ "accountNickname": "XXXXXXnt", "address": "dfspa.username.1234", "currency": "ZAR" },
{ "accountNickname": "SpeXXXXXXXXnt", "address": "dfspa.username.5678", "currency": "USD" }
{
"accountNickname": "XXXXXXnt",
"address": "dfspa.username.1234",
"currency": "{$inputs.currency2}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "dfspa.username.5678",
"currency": "{$inputs.currency}"
}
],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"callbackUri": "pisp-app://callback.com"
},
"url": "{$inputs.PISP_THIRDPARTY_SDK_OUTBOUND_URL}",
Expand Down Expand Up @@ -615,10 +658,21 @@
"OTP"
],
"accounts": [
{ "accountNickname": "XXXXXXnt", "address": "dfspa.username.1234", "currency": "ZAR" },
{ "accountNickname": "SpeXXXXXXXXnt", "address": "dfspa.username.5678", "currency": "USD" }
{
"accountNickname": "XXXXXXnt",
"address": "dfspa.username.1234",
"currency": "{$inputs.currency2}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "dfspa.username.5678",
"currency": "{$inputs.currency}"
}
],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"callbackUri": "pisp-app://callback.com"
},
"url": "{$inputs.PISP_THIRDPARTY_SDK_OUTBOUND_URL}",
Expand Down Expand Up @@ -785,15 +839,18 @@
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "244431e2-7a56-40c6-814c-932631760fa9",
"currency": "USD"
"currency": "{$inputs.currency}"
},
{
"accountNickname": "SpeXXXXXXXXnt",
"address": "6b6e6d77-dbf4-423f-abd5-bc5854e4ab1c",
"currency": "USD"
"currency": "{$inputs.currency}"
}
],
"actions": ["ACCOUNTS_GET_BALANCE", "ACCOUNTS_TRANSFER"],
"actions": [
"ACCOUNTS_GET_BALANCE",
"ACCOUNTS_TRANSFER"
],
"callbackUri": "pisp-app://callback.com"
},
"url": "{$inputs.PISP_THIRDPARTY_SDK_OUTBOUND_URL}",
Expand Down Expand Up @@ -1001,8 +1058,8 @@
},
"amountType": "SEND",
"amount": {
"amount": "100",
"currency": "USD"
"amount": "{$inputs.amount}",
"currency": "{$inputs.currency}"
},
"transactionType": {
"scenario": "TRANSFER",
Expand All @@ -1015,7 +1072,7 @@
"tests": {
"assertions": [
{
"id": 2,
"id": 1,
"description": "dynamic fields",
"exec": [
"expect(response.body.authorization.expiration).to.match(/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z/)",
Expand All @@ -1024,52 +1081,45 @@
]
},
{
"id": 1,
"description": "response body",
"id": 2,
"description": "currentState is authorizationReceived",
"exec": [
"const expected = {",
" \"authorization\": {",
" \"transactionRequestId\": \"c2470148-1be2-4c0b-aece-aa8dcb92a6cc\",",
" \"transferAmount\": {",
" \"amount\": \"100\",",
" \"currency\": \"USD\"",
" },",
" \"payeeReceiveAmount\": {",
" \"amount\": \"100\",",
" \"currency\": \"USD\"",
" },",
" \"fees\": {",
" \"amount\": \"0\",",
" \"currency\": \"USD\"",
" },",
" \"payer\": {",
" \"partyIdType\": \"THIRD_PARTY_LINK\",",
" \"partyIdentifier\": \"244431e2-7a56-40c6-814c-932631760fa9\",",
" \"fspId\": \"dfspa\"",
" },",
" \"payee\": {",
" \"partyIdInfo\": {",
" \"partyIdType\": \"MSISDN\",",
" \"partyIdentifier\": \"987654321\",",
" \"fspId\": \"dfspb\"",
" }",
" },",
" \"transactionType\": {",
" \"scenario\": \"TRANSFER\",",
" \"initiator\": \"PAYER\",",
" \"initiatorType\": \"CONSUMER\"",
" },",
" \"challenge\": \"OWZhYjAxZTcwYjU4YzRhMzRmOWQwNzBmZjllZDFiNjc2NWVhMzA1NGI1MWZjZThjZGFjNDEyZDBmNmM2MWFhMQ\"",
" },",
" \"currentState\": \"authorizationReceived\"",
"}",
"",
"// Test these dynamic variables separately",
"delete response.body.authorization.authorizationRequestId",
"delete response.body.authorization.expiration",
"",
"",
"expect(response.body).to.deep.equal(expected)"
"expect(response.body.currentState).to.equal('authorizationReceived')"
]
},
{
"id": 3,
"description": "authorization response contains transactionRequestId",
"exec": [
"expect(response.body.authorization).to.have.property('transactionRequestId')"
]
},
{
"id": 4,
"description": "authorization response contains challenge",
"exec": [
"expect(response.body.authorization).to.have.property('challenge')"
]
},
{
"id": 5,
"description": "authorization response contains transferAmount",
"exec": [
"expect(response.body.authorization).to.have.property('transferAmount')"
]
},
{
"id": 6,
"description": "transferAmount is equal to request amount",
"exec": [
"expect(response.body.authorization.transferAmount.amount).to.equal('{$inputs.amount}')"
]
},
{
"id": 7,
"description": "transferAmount currency is same as requested currency",
"exec": [
"expect(response.body.authorization.transferAmount.currency).to.equal('{$inputs.currency}')"
]
}
]
Expand Down Expand Up @@ -1148,4 +1198,4 @@
]
}
]
}
}

0 comments on commit 3fcd3c3

Please sign in to comment.