diff --git a/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get receiver wallet address.bru b/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get receiver wallet address.bru index 5df49cfc71..b8db3b4491 100644 --- a/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get receiver wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get receiver wallet address.bru @@ -41,6 +41,17 @@ script:post-response { } else { bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if ( + resourceUrl.hostname.includes('cloud-nine-wallet') || + resourceUrl.hostname.includes('happy-life-bank') + ){ + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? 3000 : 4000 + bru.setEnvVar("receiverOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("receiverOpenPaymentsHost", body?.resourceServer); + } } tests { diff --git a/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get sender wallet address.bru b/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get sender wallet address.bru index 4ed35375d7..b3bf949a66 100644 --- a/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get sender wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Open Payments Without Quote/Get sender wallet address.bru @@ -42,6 +42,14 @@ script:post-response { } else { bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if (resourceUrl.hostname.includes('cloud-nine-wallet') || resourceUrl.hostname.includes('happy-life-bank')) { + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? bru.getEnvVar('senderOpenPaymentsPort') : bru.getEnvVar('receiverOpenPaymentsPort') + bru.setEnvVar("senderOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("senderOpenPaymentsHost", body?.resourceServer); + } } tests { diff --git a/bruno/collections/Rafiki/Examples/Open Payments/Create Outgoing Payment.bru b/bruno/collections/Rafiki/Examples/Open Payments/Create Outgoing Payment.bru index e14eaa6536..6014dda378 100644 --- a/bruno/collections/Rafiki/Examples/Open Payments/Create Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Examples/Open Payments/Create Outgoing Payment.bru @@ -34,7 +34,7 @@ script:pre-request { script:post-response { const body = res.getBody(); - + if (body?.id) { bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop()); } diff --git a/bruno/collections/Rafiki/Examples/Open Payments/Get receiver wallet address.bru b/bruno/collections/Rafiki/Examples/Open Payments/Get receiver wallet address.bru index 5df49cfc71..b8db3b4491 100644 --- a/bruno/collections/Rafiki/Examples/Open Payments/Get receiver wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Open Payments/Get receiver wallet address.bru @@ -41,6 +41,17 @@ script:post-response { } else { bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if ( + resourceUrl.hostname.includes('cloud-nine-wallet') || + resourceUrl.hostname.includes('happy-life-bank') + ){ + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? 3000 : 4000 + bru.setEnvVar("receiverOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("receiverOpenPaymentsHost", body?.resourceServer); + } } tests { diff --git a/bruno/collections/Rafiki/Examples/Open Payments/Get sender wallet address.bru b/bruno/collections/Rafiki/Examples/Open Payments/Get sender wallet address.bru index 7f52d5e87c..f42f5d53bb 100644 --- a/bruno/collections/Rafiki/Examples/Open Payments/Get sender wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Open Payments/Get sender wallet address.bru @@ -41,6 +41,14 @@ script:post-response { } else { bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if (resourceUrl.hostname.includes('cloud-nine-wallet') || resourceUrl.hostname.includes('happy-life-bank')) { + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? bru.getEnvVar('senderOpenPaymentsPort') : bru.getEnvVar('receiverOpenPaymentsPort') + bru.setEnvVar("senderOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("senderOpenPaymentsHost", body?.resourceServer); + } } tests { diff --git a/bruno/collections/Rafiki/Examples/Web Monetization/Get receiver wallet address.bru b/bruno/collections/Rafiki/Examples/Web Monetization/Get receiver wallet address.bru index 41033ba257..b30f6db7a5 100644 --- a/bruno/collections/Rafiki/Examples/Web Monetization/Get receiver wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Web Monetization/Get receiver wallet address.bru @@ -42,6 +42,19 @@ script:post-response { } else { bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if ( + resourceUrl.hostname.includes('cloud-nine-wallet') || + resourceUrl.hostname.includes('happy-life-bank') + ){ + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? 3000 : 4000 + bru.setEnvVar("receiverOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("receiverOpenPaymentsHost", body?.resourceServer); + } + + } tests { diff --git a/bruno/collections/Rafiki/Examples/Web Monetization/Get sender wallet address.bru b/bruno/collections/Rafiki/Examples/Web Monetization/Get sender wallet address.bru index 7f52d5e87c..f42f5d53bb 100644 --- a/bruno/collections/Rafiki/Examples/Web Monetization/Get sender wallet address.bru +++ b/bruno/collections/Rafiki/Examples/Web Monetization/Get sender wallet address.bru @@ -41,6 +41,14 @@ script:post-response { } else { bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer); } + + const resourceUrl = url.parse(body?.resourceServer) + if (resourceUrl.hostname.includes('cloud-nine-wallet') || resourceUrl.hostname.includes('happy-life-bank')) { + const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? bru.getEnvVar('senderOpenPaymentsPort') : bru.getEnvVar('receiverOpenPaymentsPort') + bru.setEnvVar("senderOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path); + } else { + bru.setEnvVar("senderOpenPaymentsHost", body?.resourceServer); + } } tests { diff --git a/bruno/collections/Rafiki/Open Payments APIs/Outgoing Payments/Create Outgoing Payment.bru b/bruno/collections/Rafiki/Open Payments APIs/Outgoing Payments/Create Outgoing Payment.bru index 62ec4793f7..0a315cd9d6 100644 --- a/bruno/collections/Rafiki/Open Payments APIs/Outgoing Payments/Create Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Open Payments APIs/Outgoing Payments/Create Outgoing Payment.bru @@ -16,7 +16,7 @@ headers { body:json { { - "walletAddress": {{senderWalletAddress}}, + "walletAddress": "{{senderWalletAddress}}", "quoteId": "{{senderOpenPaymentsHost}}/quotes/{{quoteId}}", "metadata": { "description": "yolo", diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Approve Incoming Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Approve Incoming Payment.bru index d13c7f02cf..6a0426c85c 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Approve Incoming Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Approve Incoming Payment.bru @@ -31,5 +31,5 @@ body:graphql:vars { script:pre-request { const scripts = require('./scripts'); - scripts.addApiSignatureHeader(); + scripts.addApiSignatureHeader('backend', 'receiver'); } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Incoming Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Incoming Payment.bru index 775e508187..5568bc9635 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Incoming Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Incoming Payment.bru @@ -32,5 +32,5 @@ body:graphql:vars { script:pre-request { const scripts = require('./scripts'); - scripts.addApiSignatureHeader(); + scripts.addApiSignatureHeader('backend', 'receiver'); } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru index c1585ada96..8511ac17d6 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru @@ -68,3 +68,9 @@ body:graphql:vars { } } } + +script:pre-request { + const scripts = require('./scripts'); + + scripts.addApiSignatureHeader(); +} diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment.bru index 4861feaa69..209041819c 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment.bru @@ -45,8 +45,7 @@ body:graphql:vars { }, "incomingAmount": null, "walletAddressId": "{{walletAddressId}}" - }, - "tenantId": "{{tenantId}}" + } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru index 9878183e41..8eb7adb841 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru @@ -58,11 +58,7 @@ script:pre-request { const randomInt = Math.floor(Math.random() * (1001)); const initialRequest = bru.getEnvVar("initialWalletAddressRequest"); - - const postRequest = { - method: 'post', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ + const postRequestBody = { query: initialRequest.body.query, variables: { "input": { @@ -71,7 +67,17 @@ script:pre-request { "publicName": "Simon" } } - }) + } + + const signature = scripts.generateBackendApiSignature(postRequestBody) + const postRequest = { + method: 'post', + headers: { + 'Content-Type': 'application/json', + 'tenant-id': bru.getEnvVar('senderTenantId'), + 'signature': signature + }, + body: JSON.stringify(postRequestBody) }; const response = await fetch(`${initialRequest.url}`, postRequest); diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Tenant Settings.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Tenant Settings.bru index 757b275e6e..1cb3eef572 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Tenant Settings.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Tenant Settings.bru @@ -15,7 +15,7 @@ headers { } body:graphql { - mutation CreateTenantSettings($input: [CreateTenantSettingsInput!]!) { + mutation CreateTenantSettings($input: CreateTenantSettingsInput!) { createTenantSettings(input:$input) { settings { key @@ -27,12 +27,14 @@ body:graphql { body:graphql:vars { { - "input": [ - { - "key": "MY_KEY", - "value": "MY_VALUE" - } - ] + "input": { + "settings": [ + { + "key": "MY_KEY", + "value": "MY_VALUE" + } + ] + } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru index 951fc73170..84fd86c253 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru @@ -18,7 +18,7 @@ body:graphql { id walletAddress { id - url + address asset { id code diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru index 5ea2508c7b..c93e99844e 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru @@ -5,7 +5,7 @@ meta { } post { - address: {{RafikiGraphqlHost}}/graphql + url: {{RafikiGraphqlHost}}/graphql body: graphql auth: none } @@ -40,7 +40,7 @@ body:graphql:vars { { "input": { "assetId": "{{assetId}}", - "url": "https://{{senderOpenPaymentsHost}}/timon/{{randomId}}", + "address": "https://cloud-nine-wallet-backend/timon/{{randomId}}", "publicName": "Timon", "additionalProperties": [ {"key" : "iban", "value": "NL93 8601 1117 947", "visibleInOpenPayments": true}, diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Incoming Payment By Tenant.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Incoming Payment By Tenant.bru index 48e6c925a6..bf63ff8e20 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Incoming Payment By Tenant.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Incoming Payment By Tenant.bru @@ -5,7 +5,7 @@ meta { } post { - url: {{RafikiGraphqlHost}}/{{tenantId}}/graphql + url: {{RafikiGraphqlHost}}/graphql body: graphql auth: none } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenant Settings.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenant Settings.bru deleted file mode 100644 index 91a475a3d1..0000000000 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenant Settings.bru +++ /dev/null @@ -1,43 +0,0 @@ -meta { - name: Get Tenant Settings - type: graphql - seq: 60 -} - -post { - url: {{RafikiGraphqlHost}}/graphql - body: graphql - auth: none -} - -headers { - tenant-id: 438fa74a-fa7d-4317-9ced-dde32ece1787 -} - -body:graphql { - mutation CreateTenantSettings($input: CreateTenantSettingsInput!) { - createTenantSettings(input:$input) { - settings { - key - value - } - } - } -} - -body:graphql:vars { - { - "input": { - "settings": [ - { "key": "EXCHANGE_RATES_URL", "value": "https://example.com" } - ] - } - } - -} - -script:pre-request { - const scripts = require('./scripts'); - - scripts.addApiSignatureHeader(); -} diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenants.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenants.bru index 53f3656c4c..8709de487d 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenants.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Tenants.bru @@ -11,29 +11,21 @@ post { } body:graphql { - mutation UpdateTenant($input: UpdateTenantInput!) { - updateTenant(input:$input) { - tenant { - id - email - apiSecret - idpConsentUrl - idpSecret + query GetTenants { + tenants { + edges { + cursor + node { + id + email + apiSecret + idpConsentUrl + idpSecret + } } } } -} - -body:graphql:vars { - { - "input": { - "id": "{{tenantId}}", - "email": "updated@example.com", - "apiSecret": "updated-test-secret", - "idpConsentUrl": "https://example.com/consent-updated", - "idpSecret": "updated-test-idp-secret" - } - } + } script:pre-request { diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Addresses Keys.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Addresses Keys.bru index 57d229102b..eb34d397fd 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Addresses Keys.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Addresses Keys.bru @@ -41,3 +41,9 @@ body:graphql { } } } + +script:pre-request { + const scripts = require('./scripts'); + + scripts.addApiSignatureHeader(); +} diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Update Tenant.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Update Tenant.bru index b3f71689d8..acf2af04ce 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Update Tenant.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Update Tenant.bru @@ -29,7 +29,6 @@ body:graphql:vars { "input": { "id": "{{tenantId}}", "email": "updated@example.com", - "apiSecret": "updated-test-secret", "idpConsentUrl": "https://example.com/consent-updated", "idpSecret": "updated-test-idp-secret" } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Update Wallet Address.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Update Wallet Address.bru index 3388bad8c2..117759d139 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Update Wallet Address.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Update Wallet Address.bru @@ -22,7 +22,7 @@ body:graphql { withdrawalThreshold createdAt } - url + address publicName createdAt status diff --git a/bruno/collections/Rafiki/environments/Local Playground.bru b/bruno/collections/Rafiki/environments/Local Playground.bru index b637cb0bae..b68af87e4e 100644 --- a/bruno/collections/Rafiki/environments/Local Playground.bru +++ b/bruno/collections/Rafiki/environments/Local Playground.bru @@ -32,4 +32,7 @@ vars { assetScale: 2 senderTenantId: 438fa74a-fa7d-4317-9ced-dde32ece1787 RafikiGraphqlHostTenantId: 438fa74a-fa7d-4317-9ced-dde32ece1787 + senderOpenPaymentsPort: 3000 + receiverOpenPaymentsPort: 4000 + receiverTenantId: cf5fd7d3-1eb1-4041-8e43-ba45747e9e5d } diff --git a/bruno/collections/Rafiki/scripts.js b/bruno/collections/Rafiki/scripts.js index 654a252ca2..31dff704b4 100644 --- a/bruno/collections/Rafiki/scripts.js +++ b/bruno/collections/Rafiki/scripts.js @@ -106,7 +106,7 @@ const scripts = { return `t=${timestamp}, v${version}=${digest}` }, - addApiSignatureHeader: function (packageName) { + addApiSignatureHeader: function (packageName, instance) { const body = this.sanitizeBody() const { variables } = body const formattedBody = { @@ -127,7 +127,16 @@ const scripts = { signature = this.generateBackendApiSignature(formattedBody) } req.setHeader('signature', signature) - req.setHeader('tenant-id', bru.getEnvVar('senderTenantId')) + switch (instance) { + case 'sender': + req.setHeader('tenant-id', bru.getEnvVar('senderTenantId')) + break + case 'receiver': + req.setHeader('tenant-id', bru.getEnvVar('receiverTenantId')) + break + default: + req.setHeader('tenant-id', bru.getEnvVar('senderTenantId')) + } }, addHostHeader: function (hostVarName) { @@ -182,7 +191,8 @@ const scripts = { method: 'post', headers: { signature: this.generateBackendApiSignature(postBody), - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'tenant-id': bru.getEnvVar('senderTenantId') }, body: JSON.stringify(postBody) }