From 033bba1805b650b06094566448ca855702b8f99d Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Mon, 12 Aug 2024 12:27:32 +0530 Subject: [PATCH] feat: safe mode updates --- .../bruno-tests/collection/echo/echo json.bru | 2 +- .../collection/echo/echo plaintext.bru | 2 +- .../collection/echo/echo xml parsed.bru | 2 +- .../collection/echo/echo xml raw.bru | 2 +- .../scripting/api/bru/getEnvName.bru | 32 +++++++++++ .../scripting/api/bru/getEnvVar.bru | 27 ++++++++++ .../scripting/api/bru/getProcessEnv.bru | 27 ++++++++++ .../collection/scripting/api/bru/getVar.bru | 27 ++++++++++ .../scripting/api/bru/setEnvVar.bru | 31 +++++++++++ .../collection/scripting/api/bru/setVar.bru | 31 +++++++++++ .../collection/scripting/api/req/getBody.bru | 40 ++++++++++++++ .../scripting/api/req/getHeader.bru | 36 +++++++++++++ .../scripting/api/req/getHeaders.bru | 38 +++++++++++++ .../scripting/api/req/getMethod.bru | 32 +++++++++++ .../collection/scripting/api/req/getUrl.bru | 32 +++++++++++ .../collection/scripting/api/req/setBody.bru | 46 ++++++++++++++++ .../scripting/api/req/setHeader.bru | 40 ++++++++++++++ .../scripting/api/req/setHeaders.bru | 45 ++++++++++++++++ .../scripting/api/req/setMethod.bru | 36 +++++++++++++ .../collection/scripting/api/req/setUrl.bru | 36 +++++++++++++ .../collection/scripting/api/res/getBody.bru | 40 ++++++++++++++ .../scripting/api/res/getHeader.bru | 38 +++++++++++++ .../scripting/api/res/getHeaders.bru | 39 ++++++++++++++ .../scripting/api/res/getResponseTime.bru | 39 ++++++++++++++ .../scripting/api/res/getStatus.bru | 32 +++++++++++ .../collection/scripting/get-env-name.bru | 54 ------------------- .../collection/scripting/get-env-var.bru | 49 ----------------- .../collection/scripting/set-env-var.bru | 54 ------------------- 28 files changed, 748 insertions(+), 161 deletions(-) create mode 100644 packages/bruno-tests/collection/scripting/api/bru/getEnvName.bru create mode 100644 packages/bruno-tests/collection/scripting/api/bru/getEnvVar.bru create mode 100644 packages/bruno-tests/collection/scripting/api/bru/getProcessEnv.bru create mode 100644 packages/bruno-tests/collection/scripting/api/bru/getVar.bru create mode 100644 packages/bruno-tests/collection/scripting/api/bru/setEnvVar.bru create mode 100644 packages/bruno-tests/collection/scripting/api/bru/setVar.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/getBody.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/getHeader.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/getHeaders.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/getMethod.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/getUrl.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/setBody.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/setHeader.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/setHeaders.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/setMethod.bru create mode 100644 packages/bruno-tests/collection/scripting/api/req/setUrl.bru create mode 100644 packages/bruno-tests/collection/scripting/api/res/getBody.bru create mode 100644 packages/bruno-tests/collection/scripting/api/res/getHeader.bru create mode 100644 packages/bruno-tests/collection/scripting/api/res/getHeaders.bru create mode 100644 packages/bruno-tests/collection/scripting/api/res/getResponseTime.bru create mode 100644 packages/bruno-tests/collection/scripting/api/res/getStatus.bru delete mode 100644 packages/bruno-tests/collection/scripting/get-env-name.bru delete mode 100644 packages/bruno-tests/collection/scripting/get-env-var.bru delete mode 100644 packages/bruno-tests/collection/scripting/set-env-var.bru diff --git a/packages/bruno-tests/collection/echo/echo json.bru b/packages/bruno-tests/collection/echo/echo json.bru index 09a8ed90c..1749eda6b 100644 --- a/packages/bruno-tests/collection/echo/echo json.bru +++ b/packages/bruno-tests/collection/echo/echo json.bru @@ -1,7 +1,7 @@ meta { name: echo json type: http - seq: 1 + seq: 2 } post { diff --git a/packages/bruno-tests/collection/echo/echo plaintext.bru b/packages/bruno-tests/collection/echo/echo plaintext.bru index e6c9b3fdc..56a23d345 100644 --- a/packages/bruno-tests/collection/echo/echo plaintext.bru +++ b/packages/bruno-tests/collection/echo/echo plaintext.bru @@ -1,7 +1,7 @@ meta { name: echo plaintext type: http - seq: 2 + seq: 3 } post { diff --git a/packages/bruno-tests/collection/echo/echo xml parsed.bru b/packages/bruno-tests/collection/echo/echo xml parsed.bru index a8ff5e26a..586541664 100644 --- a/packages/bruno-tests/collection/echo/echo xml parsed.bru +++ b/packages/bruno-tests/collection/echo/echo xml parsed.bru @@ -1,7 +1,7 @@ meta { name: echo xml parsed type: http - seq: 3 + seq: 4 } post { diff --git a/packages/bruno-tests/collection/echo/echo xml raw.bru b/packages/bruno-tests/collection/echo/echo xml raw.bru index 9773d4a3d..6a02ac238 100644 --- a/packages/bruno-tests/collection/echo/echo xml raw.bru +++ b/packages/bruno-tests/collection/echo/echo xml raw.bru @@ -1,7 +1,7 @@ meta { name: echo xml raw type: http - seq: 4 + seq: 5 } post { diff --git a/packages/bruno-tests/collection/scripting/api/bru/getEnvName.bru b/packages/bruno-tests/collection/scripting/api/bru/getEnvName.bru new file mode 100644 index 000000000..ccb4f6baf --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/getEnvName.bru @@ -0,0 +1,32 @@ +meta { + name: getEnvName + type: http + seq: 1 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +script:pre-request { + const envName = bru.getEnvName(); + bru.setVar("testEnvName", envName); +} + +tests { + test("should get env name in scripts", function() { + const testEnvName = bru.getVar("testEnvName"); + expect(testEnvName).to.equal("Prod"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/bru/getEnvVar.bru b/packages/bruno-tests/collection/scripting/api/bru/getEnvVar.bru new file mode 100644 index 000000000..89af93eff --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/getEnvVar.bru @@ -0,0 +1,27 @@ +meta { + name: getEnvVar + type: http + seq: 2 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +tests { + test("should get env var in scripts", function() { + const host = bru.getEnvVar("host") + expect(host).to.equal("https://testbench-sanity.usebruno.com"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/bru/getProcessEnv.bru b/packages/bruno-tests/collection/scripting/api/bru/getProcessEnv.bru new file mode 100644 index 000000000..7e10acd47 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/getProcessEnv.bru @@ -0,0 +1,27 @@ +meta { + name: getProcessEnv + type: http + seq: 6 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +tests { + test("bru.getProcessEnv()", function() { + const v = bru.getProcessEnv("PROC_ENV_VAR"); + expect(v).to.equal("woof"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/bru/getVar.bru b/packages/bruno-tests/collection/scripting/api/bru/getVar.bru new file mode 100644 index 000000000..6883b30c8 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/getVar.bru @@ -0,0 +1,27 @@ +meta { + name: getVar + type: http + seq: 5 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +tests { + test("should get var in scripts", function() { + const testSetVar = bru.getVar("testSetVar"); + expect(testSetVar).to.equal("bruno-test-87267"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/bru/setEnvVar.bru b/packages/bruno-tests/collection/scripting/api/bru/setEnvVar.bru new file mode 100644 index 000000000..47defbcf8 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/setEnvVar.bru @@ -0,0 +1,31 @@ +meta { + name: setEnvVar + type: http + seq: 3 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +script:post-response { + bru.setEnvVar("testSetEnvVar", "bruno-29653") +} + +tests { + test("should set env var in scripts", function() { + const testSetEnvVar = bru.getEnvVar("testSetEnvVar") + expect(testSetEnvVar).to.equal("bruno-29653"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/bru/setVar.bru b/packages/bruno-tests/collection/scripting/api/bru/setVar.bru new file mode 100644 index 000000000..859166e6a --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/bru/setVar.bru @@ -0,0 +1,31 @@ +meta { + name: setVar + type: http + seq: 4 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +script:post-response { + bru.setVar("testSetVar", "bruno-test-87267") +} + +tests { + test("should get var in scripts", function() { + const testSetVar = bru.getVar("testSetVar"); + expect(testSetVar).to.equal("bruno-test-87267"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/getBody.bru b/packages/bruno-tests/collection/scripting/api/req/getBody.bru new file mode 100644 index 000000000..926144ed7 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/getBody.bru @@ -0,0 +1,40 @@ +meta { + name: getBody + type: http + seq: 9 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +tests { + test("req.getBody()", function() { + const data = res.getBody(); + expect(data).to.eql({ + "hello": "bruno" + }); + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/req/getHeader.bru b/packages/bruno-tests/collection/scripting/api/req/getHeader.bru new file mode 100644 index 000000000..c915f031c --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/getHeader.bru @@ -0,0 +1,36 @@ +meta { + name: getHeader + type: http + seq: 5 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +headers { + bruno: is-awesome +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +tests { + test("req.getHeader(name)", function() { + const h = req.getHeader('bruno'); + expect(h).to.equal("is-awesome"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/getHeaders.bru b/packages/bruno-tests/collection/scripting/api/req/getHeaders.bru new file mode 100644 index 000000000..0ca735b67 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/getHeaders.bru @@ -0,0 +1,38 @@ +meta { + name: getHeaders + type: http + seq: 7 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +headers { + bruno: is-awesome + della: is-beautiful +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +tests { + test("req.getHeaders()", function() { + const h = req.getHeaders(); + expect(h.bruno).to.equal("is-awesome"); + expect(h.della).to.equal("is-beautiful"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/getMethod.bru b/packages/bruno-tests/collection/scripting/api/req/getMethod.bru new file mode 100644 index 000000000..811c8d38c --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/getMethod.bru @@ -0,0 +1,32 @@ +meta { + name: getMethod + type: http + seq: 3 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +tests { + test("req.getMethod()()", function() { + const method = req.getMethod(); + expect(method).to.equal("GET"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/getUrl.bru b/packages/bruno-tests/collection/scripting/api/req/getUrl.bru new file mode 100644 index 000000000..ff5ad0b97 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/getUrl.bru @@ -0,0 +1,32 @@ +meta { + name: getUrl + type: http + seq: 1 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +tests { + test("req.getUrl()", function() { + const url = req.getUrl(); + expect(url).to.equal("https://testbench-sanity.usebruno.com/ping"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/setBody.bru b/packages/bruno-tests/collection/scripting/api/req/setBody.bru new file mode 100644 index 000000000..ee609bd0b --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/setBody.bru @@ -0,0 +1,46 @@ +meta { + name: setBody + type: http + seq: 10 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +script:pre-request { + req.setBody({ + "bruno": "is awesome" + }); +} + +tests { + test("req.setBody()", function() { + const data = res.getBody(); + expect(data).to.eql({ + "bruno": "is awesome" + }); + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/req/setHeader.bru b/packages/bruno-tests/collection/scripting/api/req/setHeader.bru new file mode 100644 index 000000000..de172e533 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/setHeader.bru @@ -0,0 +1,40 @@ +meta { + name: setHeader + type: http + seq: 6 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +headers { + bruno: is-awesome +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +script:pre-request { + req.setHeader('bruno', 'is-the-future'); +} + +tests { + test("req.setHeader(name)", function() { + const h = req.getHeader('bruno'); + expect(h).to.equal("is-the-future"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/setHeaders.bru b/packages/bruno-tests/collection/scripting/api/req/setHeaders.bru new file mode 100644 index 000000000..f17ce7389 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/setHeaders.bru @@ -0,0 +1,45 @@ +meta { + name: setHeaders + type: http + seq: 8 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +headers { + bruno: is-awesome + della: is-beautiful +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +script:pre-request { + req.setHeaders({ + "content-type": "application/text", + "transaction-id": "foobar" + }); +} + +tests { + test("req.setHeaders()", function() { + const h = req.getHeaders(); + expect(h['content-type']).to.equal("application/text"); + expect(h['transaction-id']).to.equal("foobar"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/setMethod.bru b/packages/bruno-tests/collection/scripting/api/req/setMethod.bru new file mode 100644 index 000000000..69ddac510 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/setMethod.bru @@ -0,0 +1,36 @@ +meta { + name: setMethod + type: http + seq: 4 +} + +post { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +script:pre-request { + req.setMethod("GET"); +} + +tests { + test("req.setMethod()()", function() { + const method = req.getMethod(); + expect(method).to.equal("GET"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/req/setUrl.bru b/packages/bruno-tests/collection/scripting/api/req/setUrl.bru new file mode 100644 index 000000000..5c66b9104 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/req/setUrl.bru @@ -0,0 +1,36 @@ +meta { + name: setUrl + type: http + seq: 2 +} + +get { + url: {{host}}/ping/invalid + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +script:pre-request { + req.setUrl("https://testbench-sanity.usebruno.com/ping"); +} + +tests { + test("req.setUrl()", function() { + const url = req.getUrl(); + expect(url).to.equal("https://testbench-sanity.usebruno.com/ping"); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/api/res/getBody.bru b/packages/bruno-tests/collection/scripting/api/res/getBody.bru new file mode 100644 index 000000000..521d36a01 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/res/getBody.bru @@ -0,0 +1,40 @@ +meta { + name: getBody + type: http + seq: 4 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +tests { + test("res.getBody()", function() { + const data = res.getBody(); + expect(data).to.eql({ + "hello": "bruno" + }); + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/res/getHeader.bru b/packages/bruno-tests/collection/scripting/api/res/getHeader.bru new file mode 100644 index 000000000..1ab640726 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/res/getHeader.bru @@ -0,0 +1,38 @@ +meta { + name: getHeader + type: http + seq: 2 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +tests { + test("res.getHeader(name)", function() { + const server = res.getHeader('x-powered-by'); + expect(server).to.eql('Express'); + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/res/getHeaders.bru b/packages/bruno-tests/collection/scripting/api/res/getHeaders.bru new file mode 100644 index 000000000..58dc7495d --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/res/getHeaders.bru @@ -0,0 +1,39 @@ +meta { + name: getHeaders + type: http + seq: 3 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +tests { + test("res.getHeaders(name)", function() { + const h = res.getHeaders(); + expect(h['x-powered-by']).to.eql('Express'); + expect(h['content-length']).to.eql('17'); + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/res/getResponseTime.bru b/packages/bruno-tests/collection/scripting/api/res/getResponseTime.bru new file mode 100644 index 000000000..236a5eff1 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/res/getResponseTime.bru @@ -0,0 +1,39 @@ +meta { + name: getResponseTime + type: http + seq: 5 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +tests { + test("res.getResponseTime()", function() { + const responseTime = res.getResponseTime(); + expect(typeof responseTime).to.eql("number"); + expect(responseTime > 0).to.be.true; + }); + +} diff --git a/packages/bruno-tests/collection/scripting/api/res/getStatus.bru b/packages/bruno-tests/collection/scripting/api/res/getStatus.bru new file mode 100644 index 000000000..a1fa5cea0 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/api/res/getStatus.bru @@ -0,0 +1,32 @@ +meta { + name: getStatus + type: http + seq: 1 +} + +get { + url: {{host}}/ping + body: none + auth: none +} + +auth:awsv4 { + accessKeyId: a + secretAccessKey: b + sessionToken: c + service: d + region: e + profileName: f +} + +assert { + res.status: eq 200 + res.body: eq pong +} + +tests { + test("res.getStatus()", function() { + const status = res.getStatus() + expect(status).to.equal(200); + }); +} \ No newline at end of file diff --git a/packages/bruno-tests/collection/scripting/get-env-name.bru b/packages/bruno-tests/collection/scripting/get-env-name.bru deleted file mode 100644 index bce2d1973..000000000 --- a/packages/bruno-tests/collection/scripting/get-env-name.bru +++ /dev/null @@ -1,54 +0,0 @@ -meta { - name: get-env-name - type: http - seq: 1 -} - -get { - url: {{host}}/ping - body: none - auth: none -} - -auth:awsv4 { - accessKeyId: a - secretAccessKey: b - sessionToken: c - service: d - region: e - profileName: f -} - -script:pre-request { - const envName = bru.getEnvName(); - bru.setVar("testEnvName", envName); -} - -tests { - test("should get env name in scripts", function() { - const testEnvName = bru.getVar("testEnvName"); - expect(testEnvName).to.equal("Prod"); - }); -} - -docs { - # API Documentation - - ## Introduction - - Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. - - ## Authentication - - Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: - - ### API Key - - To use API key authentication, include your API key in the request headers as follows: - - ```http - GET /api/endpoint - Host: api.example.com - Authorization: Bearer YOUR_API_KEY - -} diff --git a/packages/bruno-tests/collection/scripting/get-env-var.bru b/packages/bruno-tests/collection/scripting/get-env-var.bru deleted file mode 100644 index 5c9d8ec5d..000000000 --- a/packages/bruno-tests/collection/scripting/get-env-var.bru +++ /dev/null @@ -1,49 +0,0 @@ -meta { - name: get-env-var - type: http - seq: 2 -} - -get { - url: {{host}}/ping - body: none - auth: none -} - -auth:awsv4 { - accessKeyId: a - secretAccessKey: b - sessionToken: c - service: d - region: e - profileName: f -} - -tests { - test("should get env var in scripts", function() { - const host = bru.getEnvVar("host") - expect(host).to.equal("https://testbench-sanity.usebruno.com"); - }); -} - -docs { - # API Documentation - - ## Introduction - - Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. - - ## Authentication - - Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: - - ### API Key - - To use API key authentication, include your API key in the request headers as follows: - - ```http - GET /api/endpoint - Host: api.example.com - Authorization: Bearer YOUR_API_KEY - -} diff --git a/packages/bruno-tests/collection/scripting/set-env-var.bru b/packages/bruno-tests/collection/scripting/set-env-var.bru deleted file mode 100644 index f193dbe88..000000000 --- a/packages/bruno-tests/collection/scripting/set-env-var.bru +++ /dev/null @@ -1,54 +0,0 @@ -meta { - name: set-env-var - type: http - seq: 3 -} - -get { - url: {{host}}/ping - body: none - auth: none -} - -auth:awsv4 { - accessKeyId: a - secretAccessKey: b - sessionToken: c - service: d - region: e - profileName: f -} - -script:post-response { - bru.setEnvVar("testSetEnvVar", "bruno-29653") -} - -tests { - test("should set env var in scripts", function() { - const testSetEnvVar = bru.getEnvVar("testSetEnvVar") - console.log(testSetEnvVar); - expect(testSetEnvVar).to.equal("bruno-29653"); - }); -} - -docs { - # API Documentation - - ## Introduction - - Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. - - ## Authentication - - Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: - - ### API Key - - To use API key authentication, include your API key in the request headers as follows: - - ```http - GET /api/endpoint - Host: api.example.com - Authorization: Bearer YOUR_API_KEY - -}