Skip to content

Commit 7845a5f

Browse files
committed
Added test requests for cookies + related changes in testbench server
Also in bruno-testbench(packages/bruno-tests) server - Added `/api/echo/trace` API which returns all the request details as an JSON response - Added SSL support for `localhost`
1 parent 7c07488 commit 7845a5f

28 files changed

+410
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: cookies
3+
seq: 13
4+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
meta {
2+
name: simple cookie response
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: {{host}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "foo=bar"
18+
},
19+
"content": "hello"
20+
}
21+
}
22+
23+
assert {
24+
res.headers["set-cookie"][0]: eq foo=bar
25+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+local-ipv4+http
3+
seq: 5
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: http://127.0.0.1:{{http_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "secure-local-ipv4-http=val; Secure"
18+
},
19+
"content": "hello"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: http://127.0.0.1:{{http_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains secure-local-ipv4-http=val
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+local-ipv4+https
3+
seq: 6
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: https://127.0.0.1:{{https_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "secure-local-ipv4-https=val; Secure"
18+
},
19+
"content": "hello"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: https://127.0.0.1:{{https_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains secure-local-ipv4-https=val
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+localhost+http
3+
seq: 3
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: http://localhost:{{http_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "secure-localhost-http=val; Secure"
18+
},
19+
"content": "hello"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: http://localhost:{{http_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains secure-localhost-http=val
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+localhost+https
3+
seq: 4
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: https://localhost:{{https_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "secure-localhost-https=val; Secure"
18+
},
19+
"content": "hello"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: https://localhost:{{https_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains secure-localhost-https=val
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+non-local+http
3+
seq: 7
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: http://internal:{{http_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": [
18+
"secure-non-local-http=val; Secure",
19+
"secure-non-local-http-key2=val"
20+
]
21+
},
22+
"content": "hello"
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: http://internal:{{http_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: notContains secure-non-local-http=val
15+
res.body.headers.cookie: contains secure-non-local-http-key2=val
16+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test secure+non-local+https
3+
seq: 8
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: https://internal:{{https_port}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": [
18+
"secure-non-local-https=val; Secure",
19+
"secure-non-local-https-key2=val"
20+
]
21+
},
22+
"content": "hello"
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: https://internal:{{https_port}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains secure-non-local-https=val
15+
res.body.headers.cookie: contains secure-non-local-https-key2=val
16+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: test set-cookie basic
3+
seq: 1
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
meta {
2+
name: set the cookie
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: {{host}}/api/echo/custom
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"type": "text/plain",
16+
"headers": {
17+
"set-cookie": "basic=val"
18+
},
19+
"content": "hello"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
meta {
2+
name: verify the cookie in request
3+
type: http
4+
seq: 2
5+
}
6+
7+
post {
8+
url: {{host}}/api/echo/trace
9+
body: none
10+
auth: inherit
11+
}
12+
13+
assert {
14+
res.body.headers.cookie: contains basic=val
15+
}

packages/bruno-tests/collection/environments/Local.bru

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
vars {
2-
host: http://localhost:8080
2+
http_port: 8081
3+
https_port: 8082
4+
host: http://localhost:{{http_port}}
5+
host_https: https://localhost:{{https_port}}
36
httpfaker: https://www.httpfaker.org
47
bearer_auth_token: your_secret_token
58
basic_auth_password: della

packages/bruno-tests/src/echo/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,16 @@ router.post("/custom", (req, res) => {
7474
return res.end();
7575
});
7676

77+
router.all('/trace', (req, res) => {
78+
const requestDetails = {
79+
url: req.url,
80+
method: req.method,
81+
query: req.query,
82+
headers: req.headers,
83+
body: req.body,
84+
rawBody: req.rawBody
85+
};
86+
res.json(requestDetails);
87+
});
88+
7789
module.exports = router;

0 commit comments

Comments
 (0)