Skip to content

Commit 0ecb1ba

Browse files
committed
add basic_auth test
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
1 parent eb6934f commit 0ecb1ba

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Configure Caddy
2+
POST http://localhost:2019/load
3+
Content-Type: text/caddyfile
4+
```
5+
{
6+
skip_install_trust
7+
http_port 9080
8+
https_port 9443
9+
local_certs
10+
debug
11+
}
12+
localhost {
13+
log
14+
basic_auth {
15+
john $2a$14$x4HlYwA9Zeer4RkMEYbUzug9XxWmncneR.dcMs.UjalR95URnHg5.
16+
}
17+
respond "Hello, World!"
18+
}
19+
```
20+
21+
# requests without `Authorization` header are rejected with 401
22+
GET https://localhost:9443
23+
[Options]
24+
insecure: true
25+
HTTP 401
26+
[Asserts]
27+
header "WWW-Authenticate" == "Basic realm=\"restricted\""
28+
29+
30+
# requests with `Authorization` header are accepted with 200
31+
GET https://localhost:9443
32+
[BasicAuth]
33+
john:password
34+
[Options]
35+
insecure: true
36+
HTTP 200
37+
[Asserts]
38+
`Hello, World!`

0 commit comments

Comments
 (0)