Skip to content

Commit

Permalink
feat: update bruno requests, fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Feb 3, 2025
1 parent d1785a2 commit 88cf1f5
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}/continue/{{continueId}}
url: {{senderOpenPaymentsAuthHost}}/continue/{{continueId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("senderAssetCode", body?.assetCode)
bru.setEnvVar("senderAssetScale", body?.assetScale)

Expand All @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}/continue/{{continueId}}
url: {{senderOpenPaymentsAuthHost}}/continue/{{continueId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ script:pre-request {

script:post-response {
const url = require('url')

if (res.getStatus() !== 200) {
return
}

const body = res.getBody()
bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)
Expand All @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}/continue/{{continueId}}
url: {{senderOpenPaymentsAuthHost}}/continue/{{continueId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)

Expand All @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}/continue/{{continueId}}
url: {{receiverOpenPaymentsAuthHost}}/continue/{{continueId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
3 changes: 1 addition & 2 deletions bruno/collections/Rafiki/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ const scripts = {
signature = this.generateBackendApiSignature(formattedBody)
}
req.setHeader('signature', signature)
req.setHeader( 'tenant-id', bru.getEnvVar('senderTenantId'))

req.setHeader('tenant-id', bru.getEnvVar('senderTenantId'))
},

addHostHeader: function (hostVarName) {
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ export function initIocContainer(
})
container.singleton('remoteIncomingPaymentService', async (deps) => {
return await createRemoteIncomingPaymentService({
config: await deps.use('config'),
logger: await deps.use('logger'),
knex: await deps.use('knex'),
grantService: await deps.use('grantService'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function getIncomingPaymentPublic(
}

ctx.body = incomingPayment.toPublicOpenPaymentsType(
`${deps.config.authServerGrantUrl}/${deps.config.operatorTenantId}` // TODO: update this when tenanted incoming payments added
`${deps.config.authServerGrantUrl}/${incomingPayment?.walletAddress?.tenantId}`
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Remote Incoming Payment Service', (): void => {

expect(incomingPayment).toStrictEqual(mockedIncomingPayment)
expect(grantGetOrCreateSpy).toHaveBeenCalledWith({
authServer: walletAddress.authServer + '/' + Config.operatorTenantId, // TODO: replace with wallet address tenant id once wallet addresses are tenanted
authServer: walletAddress.authServer,
accessType: AccessType.IncomingPayment,
accessActions: [AccessAction.Create, AccessAction.ReadAll]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function createIncomingPayment(
walletAddress.resourceServer ?? new URL(walletAddress.id).origin

const grantOptions = {
authServer: urlWithoutTenantId(walletAddress.authServer),
authServer: walletAddress.authServer,
accessType: AccessType.IncomingPayment,
accessActions: [AccessAction.Create, AccessAction.ReadAll]
}
Expand Down Expand Up @@ -217,7 +217,7 @@ async function getIncomingPayment(
OpenPaymentsIncomingPaymentWithPaymentMethods | RemoteIncomingPaymentError
> {
const grantOptions = {
authServer: urlWithoutTenantId(authServerUrl),
authServer: authServerUrl,
accessType: AccessType.IncomingPayment,
accessActions: [AccessAction.ReadAll]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ describe('Wallet Address Routes', (): void => {
assetCode: walletAddress.asset.code,
assetScale: walletAddress.asset.scale,
// Ensure the tenant id is returned for auth and resource server:
authServer: `${config.authServerGrantUrl}/${config.operatorTenantId}`,
resourceServer: `${config.openPaymentsUrl}/${config.operatorTenantId}`
authServer: `${config.authServerGrantUrl}/${walletAddress.tenantId}`,
resourceServer: `${config.openPaymentsUrl}/${walletAddress.tenantId}`
})
})
})
Expand Down
10 changes: 5 additions & 5 deletions test/integration/lib/test-actions/open-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ async function grantRequestIncomingPayment(
deps: OpenPaymentsActionsDeps,
receiverWalletAddress: WalletAddress
): Promise<Grant> {
const { sendingASE, receivingASE } = deps
const { sendingASE } = deps

const grant = await sendingASE.opClient.grant.request(
{
url: urlWithoutTenantId(receiverWalletAddress.authServer)
url: receiverWalletAddress.authServer
},
{
access_token: {
Expand Down Expand Up @@ -191,7 +191,7 @@ async function grantRequestQuote(
const { sendingASE } = deps
const grant = await sendingASE.opClient.grant.request(
{
url: urlWithoutTenantId(senderWalletAddress.authServer)
url: senderWalletAddress.authServer
},
{
access_token: {
Expand Down Expand Up @@ -238,10 +238,10 @@ async function grantRequestOutgoingPayment(
limits: GrantRequestPaymentLimits,
finish?: InteractFinish
): Promise<PendingGrant> {
const { receivingASE, sendingASE } = deps
const { receivingASE } = deps
const grant = await receivingASE.opClient.grant.request(
{
url: urlWithoutTenantId(senderWalletAddress.authServer)
url: senderWalletAddress.authServer
},
{
access_token: {
Expand Down

0 comments on commit 88cf1f5

Please sign in to comment.