Skip to content

Commit

Permalink
chore: fix OP example
Browse files Browse the repository at this point in the history
  • Loading branch information
sabineschaller committed Feb 16, 2024
1 parent ee30f87 commit ff0c791
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 390 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@ headers {

body:json {
{
"interact_ref": "6d519566-234f-4c2e-b56f-6d4a305fc067"
"interact_ref": "8c55602c-f777-44cf-bbe7-f4f6589d6aeb"
}
}

script:pre-request {
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

await scripts.addSignatureHeaders();
}

script:post-response {
const body = res.getBody();
bru.setEnvVar("accessToken", body.access_token.value);
bru.setEnvVar("tokenId", body.access_token.manage.split('/').pop())
}

tests {
// const body = pm.response.json();
// pm.environment.set("accessToken", body.access_token.value);
// pm.environment.set("tokenId", body.access_token.manage.split('/').pop())
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ body:json {
}

script:pre-request {
// pm.environment.set("tomorrow", (new Date(new Date().setDate(new Date().getDate() + 1))).toISOString());
//
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
//
const scripts = require('./scripts/scripts');

bru.setEnvVar("tomorrow", (new Date(new Date().setDate(new Date().getDate() + 1))).toISOString());

scripts.addHostHeader();

await scripts.addSignatureHeaders();
}

script:post-response {
const body = res.getBody();
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());

}

tests {
// pm.test("Status code is 201", function () {
// pm.response.to.have.status(201);
// });
//
// const body = pm.response.json();
// pm.environment.set("incomingPaymentId", body.id.split("/").pop());
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ body:json {
}

script:pre-request {
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

scripts.addHostHeader();

await scripts.addSignatureHeaders();
}

script:post-response {
const body = res.getBody();
bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop());

}

tests {
// pm.test("Status code is 201", function () {
// pm.response.to.have.status(201);
// });
//
// const body = pm.response.json();
// pm.environment.set("outgoingPaymentId", body.id.split("/").pop());
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@ body:json {
}

script:pre-request {
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

scripts.addHostHeader();

await scripts.addSignatureHeaders();
}

script:post-response {
const body = res.getBody();
bru.setEnvVar("quoteId", body.id.split("/").pop());
bru.setEnvVar("quoteDebitAmount", JSON.stringify(body.debitAmount))
bru.setEnvVar("quoteReceiveAmount", JSON.stringify(body.receiveAmount))

}

tests {
// pm.test("Status code is 201", function () {
// pm.response.to.have.status(201);
// });
//
// const body = pm.response.json();
// pm.environment.set("quoteId", body.id.split("/").pop());
// pm.environment.set("quoteDebitAmount", JSON.stringify(body.debitAmount))
// pm.environment.set("quoteReceiveAmount", JSON.stringify(body.receiveAmount))
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ headers {
}

script:pre-request {
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

scripts.addHostHeader();

await scripts.addSignatureHeaders();
}

tests {
// pm.test("Status code is 200", function () {
// pm.response.to.have.status(200);
// });
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,32 @@ headers {
}

script:pre-request {
// const url = require('url')
//
// const requestUrl = url.parse(request.url
// .replace(/{{([A-Za-z]\w+)}}/g, (_, key) => pm.environment.get(key)))
//
// pm.environment.set("receiverOpenPaymentsHost", requestUrl.protocol + '//' + requestUrl.host);
//
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
const scripts = require('./scripts/scripts');

scripts.addHostHeader("receiverOpenPaymentsHost");
}

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

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

const authUrl = url.parse(body?.authServer)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
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 );
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
}

tests {
// const url = require('url')
//
// pm.test("Status code is 200", function () {
// pm.response.to.have.status(200);
// });
//
// const body = pm.response.json();
// pm.environment.set("receiverAssetCode", body?.assetCode)
// pm.environment.set("receiverAssetScale", body?.assetScale)
//
// const authUrl = url.parse(body?.authServer)
// if (
// authUrl.hostname.includes('cloud-nine-wallet') ||
// authUrl.hostname.includes('happy-life-bank')
// ){
// const port = authUrl.hostname.includes('cloud-nine-wallet')
// ? authUrl.port
// : Number(authUrl.port) + 1000
// pm.environment.set("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
// } else {
// pm.environment.set("receiverOpenPaymentsAuthHost", body?.authServer);
// }
//
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ headers {
}

script:pre-request {
const url = require('url')

const requestUrl = url.parse(req.url
.replace(/{{([A-Za-z]\w+)}}/g, (_, key) => bru.getEnvVar(key)))

bru.setEnvVar("senderOpenPaymentsHost", requestUrl.protocol + '//' + requestUrl.host);

// if(bru.getEnvVar('preRequestHost')){
// eval(bru.getEnvVar('preRequestHost'))
// }
const scripts = require('./scripts/scripts');

if(requestUrl.hostname === 'localhost'){
const hostHeader = requestUrl.port === '3000'? bru.getEnvVar('host3000'): bru.getEnvVar('host4000')
req.headers.host = hostHeader
}
scripts.addHostHeader("senderOpenPaymentsHost");
}

script:post-response {
Expand All @@ -49,9 +37,6 @@ script:post-response {
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}



}

tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ body:json {
}

script:pre-request {
// eval(pm.environment.get('preRequestSignatures'))
//
const scripts = require('./scripts/scripts');

await scripts.addSignatureHeaders();
}

script:post-response {
const scripts = require('./scripts/scripts');

scripts.storeTokenDetails();
}

tests {
// const body = pm.response.json();
// pm.environment.set("accessToken", body?.access_token?.value);
// pm.environment.set("continueToken", body.continue.access_token.value);
// pm.environment.set("continueId", body.continue.uri.split("/").pop());
// pm.environment.set("tokenId", body.access_token.manage.split('/').pop())
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ body:json {
}

script:pre-request {
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

await scripts.addSignatureHeaders();
}

script:post-response {
const scripts = require('./scripts/scripts');

scripts.storeTokenDetails();
}

tests {
// const body = pm.response.json();
// pm.environment.set("accessToken", body?.access_token?.value);
// pm.environment.set("continueToken", body.continue.access_token.value);
// pm.environment.set("continueId", body.continue.uri.split("/").pop());
//
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ body:json {
}

script:pre-request {
// eval(pm.environment.get('preRequestSignatures'))
const scripts = require('./scripts/scripts');

await scripts.addSignatureHeaders();
}

script:post-response {
const scripts = require('./scripts/scripts');

scripts.storeTokenDetails();
}

tests {
// const body = pm.response.json();
// pm.environment.set("accessToken", body?.access_token?.value);
// pm.environment.set("continueToken", body.continue.access_token.value);
// pm.environment.set("continueId", body.continue.uri.split("/").pop());
// pm.environment.set("tokenId", body.access_token.manage.split('/').pop())
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Loading

0 comments on commit ff0c791

Please sign in to comment.