feat: safe mode updates

This commit is contained in:
Anoop M D
2024-08-12 12:27:32 +05:30
parent 4fcb6f0980
commit 033bba1805
28 changed files with 748 additions and 161 deletions

View File

@@ -1,7 +1,7 @@
meta {
name: echo json
type: http
seq: 1
seq: 2
}
post {

View File

@@ -1,7 +1,7 @@
meta {
name: echo plaintext
type: http
seq: 2
seq: 3
}
post {

View File

@@ -1,7 +1,7 @@
meta {
name: echo xml parsed
type: http
seq: 3
seq: 4
}
post {

View File

@@ -1,7 +1,7 @@
meta {
name: echo xml raw
type: http
seq: 4
seq: 5
}
post {

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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"
});
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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"
});
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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");
});
}

View File

@@ -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"
});
});
}

View File

@@ -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');
});
}

View File

@@ -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');
});
}

View File

@@ -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;
});
}

View File

@@ -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);
});
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}