1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

add accesslog+proxy example

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-19 17:47:44 +03:00
parent fc2aada3c7
commit a04a6b5011
9 changed files with 199 additions and 28 deletions

View File

@@ -17,29 +17,35 @@ func TestReadHeaders(t *testing.T) {
headers map[string]string
code int
body string
regex bool
}{
{headers: map[string]string{
"X-Request-Id": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
"Authentication": "Bearer my-token",
}, code: 200, body: expectedOKBody},
}, code: 200, body: expectedOKBody, regex: false},
{headers: map[string]string{
"x-request-id": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
"authentication": "Bearer my-token",
}, code: 200, body: expectedOKBody},
}, code: 200, body: expectedOKBody, regex: false},
{headers: map[string]string{
"X-Request-ID": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
"X-Request-Id": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
"Authentication": "Bearer my-token",
}, code: 200, body: expectedOKBody},
}, code: 200, body: expectedOKBody, regex: false},
{headers: map[string]string{
"Authentication": "Bearer my-token",
}, code: 500, body: "X-Request-Id is empty"},
}, code: 500, body: "X-Request-Id is empty", regex: false},
{headers: map[string]string{
"X-Request-ID": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
}, code: 500, body: "Authentication is empty"},
{headers: map[string]string{}, code: 500, body: "X-Request-Id is empty (and 1 other error)"},
"X-Request-Id": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
}, code: 500, body: "Authentication is empty", regex: false},
{headers: map[string]string{}, code: 500, body: ".*\\(and 1 other error\\)$", regex: true},
}
for _, tt := range tests {
e.GET("/").WithHeaders(tt.headers).Expect().Status(tt.code).Body().Equal(tt.body)
te := e.GET("/").WithHeaders(tt.headers).Expect().Status(tt.code).Body()
if tt.regex {
te.Match(tt.body)
} else {
te.Equal(tt.body)
}
}
}