-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy_test.go
39 lines (29 loc) · 862 Bytes
/
proxy_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Client code
package proxy
import "testing"
const maxCount = 2
func Test_proxy(t *testing.T) {
nginxServer := newNginxServer(maxCount)
appStatusURL := "/app/status"
createUserURL := "/create/user"
for i := 0; i < maxCount; i++ {
httpCode, body := nginxServer.handleRequest(appStatusURL, "GET")
if httpCode != 200 || body != "Ok" {
t.Error("Wrong GET API")
}
}
httpCode, body := nginxServer.handleRequest(appStatusURL, "GET")
if httpCode != 403 || body != "Not Allowed" {
t.Error("Wrong GET API")
}
for i := 0; i < maxCount; i++ {
httpCode, body := nginxServer.handleRequest(createUserURL, "POST")
if httpCode != 201 || body != "User Created" {
t.Error("Wrong POST API")
}
}
httpCode, body = nginxServer.handleRequest(createUserURL, "POST")
if httpCode != 403 || body != "Not Allowed" {
t.Error("Wrong POST API")
}
}