-
Notifications
You must be signed in to change notification settings - Fork 110
fix: fix Create Quote Bruno pre-request script #3883
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,25 +51,34 @@ body:graphql:vars { | |
|
|
||
| script:pre-request { | ||
| // Create an additional wallet address to represent the account that will be sending money | ||
|
|
||
| const fetch = require('node-fetch'); | ||
| const scripts = require('./scripts'); | ||
|
|
||
| const randomInt = Math.floor(Math.random() * (1001)); | ||
|
|
||
| const initialRequest = bru.getEnvVar("initialWalletAddressRequest"); | ||
| const postRequestBody = { | ||
| query: initialRequest.body.query, | ||
| variables: { | ||
| "input": { | ||
| "assetId": bru.getEnvVar("assetId"), | ||
| "url": "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt, | ||
| "publicName": "Simon" | ||
|
|
||
| const createWalletAddressQuery = ` | ||
| mutation CreateWalletAddress($input: CreateWalletAddressInput!) { | ||
| createWalletAddress(input: $input) { | ||
| walletAddress { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const postRequestBody = { | ||
| query: createWalletAddressQuery, | ||
| variables: { | ||
| input: { | ||
| assetId: bru.getEnvVar("assetId"), | ||
| url: "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt, | ||
| publicName: "Simon" | ||
| } | ||
| } | ||
|
|
||
| const signature = scripts.generateBackendApiSignature(postRequestBody) | ||
| }; | ||
|
|
||
| const signature = scripts.generateBackendApiSignature(postRequestBody); | ||
| const postRequest = { | ||
| method: 'post', | ||
| headers: { | ||
|
|
@@ -79,11 +88,12 @@ script:pre-request { | |
| }, | ||
| body: JSON.stringify(postRequestBody) | ||
| }; | ||
|
|
||
| const response = await fetch(`${initialRequest.url}`, postRequest); | ||
|
|
||
| const graphqlUrl = bru.getEnvVar("RafikiGraphqlHost") + "/graphql"; | ||
| const response = await fetch(graphqlUrl, postRequest); | ||
| const body = await response.json(); | ||
| bru.setEnvVar("secondWalletAddressId", body.data.createWalletAddress.walletAddress.id); | ||
|
Comment on lines
+92
to
95
|
||
|
|
||
| scripts.addApiSignatureHeader(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -65,7 +65,6 @@ script:post-response { | |||||
| if (body?.data) { | ||||||
| bru.setEnvVar("walletAddressId", body.data.createWalletAddress.walletAddress.id); | ||||||
| bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.url); | ||||||
|
||||||
| bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.url); | |
| bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre-request script builds the wallet address URL using
bru.getEnvVar("OpenPaymentsHost"), but this env var isn’t defined anywhere in the repository’s Rafiki Bruno environments (onlysenderOpenPaymentsHost/receiverOpenPaymentsHostpatterns are used elsewhere). This likely produceshttps://undefined/...URLs by default. Consider switching to an existing env var that is actually set in the collection flow (e.g., the sender Open Payments host) or addingOpenPaymentsHostto the committed environment templates/docs so the request is reproducible.