Skip to content

Commit

Permalink
chore: clean up bruno scripts and tests (#2634)
Browse files Browse the repository at this point in the history
* chore: clean up bruno scripts and tests

* fix: remove auth header

* fix: remove host header
  • Loading branch information
sabineschaller authored Apr 11, 2024
1 parent 4e3894b commit 3d49249
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ post {

headers {
Authorization: GNAP {{accessToken}}
~Host: happy-life-bank-backend
}

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

scripts.addHostHeader();

await scripts.addSignatureHeaders();
}

tests {
test("Status code is 200", function() {
expect(res.getStatus()).to.equal(200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ 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');

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 201", function() {
expect(res.getStatus()).to.equal(201);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ get {

headers {
Host: happy-life-bank-backend
~Authorization: GNAP {{accessToken}}
}

script:pre-request {
//
}

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,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.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 @@ -21,33 +21,15 @@ headers {
}

script:pre-request {
// request.url = request.url
// .replace(/{{(receiverWalletAddress)}}/g, (_, key) => pm.environment.get(key))
// .replace(/http:\/\/localhost:([3,4])000/g, (_, key) =>
// key === '3'
// ? 'https://' + pm.environment.get('host3000')
// : 'https://' + pm.environment.get('host4000')
// )
// console.log(request.url)
//
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
//
// pm.request.url.query.idx(2).value = pm.request.url.query.idx(2).value
// .replace(/{{([A-Za-z]\w+)}}/g, (_, key) => pm.environment.get(key))
// .replace(/http:\/\/localhost:([3,4])000/g, (_, key) =>
// key === '3'
// ? 'https://' + pm.environment.get('host3000')
// : 'https://' + pm.environment.get('host4000')
// )
//
const scripts = require('./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 @@ -26,18 +26,20 @@ 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.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 201", function() {
expect(res.getStatus()).to.equal(201);
});
}
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.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 @@ -21,33 +21,15 @@ headers {
}

script:pre-request {
// request.url = request.url
// .replace(/{{(senderWalletAddress)}}/g, (_, key) => pm.environment.get(key))
// .replace(/http:\/\/localhost:([3,4])000/g, (_, key) =>
// key === '3'
// ? 'https://' + pm.environment.get('host3000')
// : 'https://' + pm.environment.get('host4000')
// )
// console.log(request.url)
//
// if(pm.environment.get('preRequestHost')){
// eval(pm.environment.get('preRequestHost'))
// }
// eval(pm.environment.get('preRequestSignatures'))
//
// pm.request.url.query.idx(2).value = pm.request.url.query.idx(2).value
// .replace(/{{([A-Za-z]\w+)}}/g, (_, key) => pm.environment.get(key))
// .replace(/http:\/\/localhost:([3,4])000/g, (_, key) =>
// key === '3'
// ? 'https://' + pm.environment.get('host3000')
// : 'https://' + pm.environment.get('host4000')
// )
//
const scripts = require('./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);
});
}
27 changes: 16 additions & 11 deletions bruno/collections/Rafiki/Open Payments APIs/Quotes/Create Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,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.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());
//
test("Status code is 201", function() {
expect(res.getStatus()).to.equal(201);
});
}
16 changes: 8 additions & 8 deletions bruno/collections/Rafiki/Open Payments APIs/Quotes/Get Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,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.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 @@ -11,7 +11,13 @@ get {
}

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

scripts.addHostHeader("senderOpenPaymentsHost");
}

tests {
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,30 +15,13 @@ headers {
}

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

scripts.addHostHeader("senderOpenPaymentsHost");
}

tests {
// 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 @@ -31,9 +31,3 @@ script:post-response {

scripts.storeTokenDetails();
}

tests {
// const body = pm.response.json();
// pm.environment.set("accessToken", body.access_token.value);
// pm.environment.set("tokenId", body.access_token.manage.split('/').pop())
}
6 changes: 0 additions & 6 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Create Peer.bru
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ script:post-response {

bru.setEnvVar("peerId", body.data.createPeer.peer.id);
}

tests {
// const body = pm.response.json();
//
// pm.environment.set("peerId", body.data.createPeer.peer.id);
}

0 comments on commit 3d49249

Please sign in to comment.