projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
4869: Keepstore now returns Content-Length headers, and logs the error message
[arvados.git]
/
services
/
keepstore
/
handler_test.go
diff --git
a/services/keepstore/handler_test.go
b/services/keepstore/handler_test.go
index fbf4ef32521742e8f60d59814d696200eba80db6..3f0b56062b222b72216ad126172fe91edafcd24b 100644
(file)
--- a/
services/keepstore/handler_test.go
+++ b/
services/keepstore/handler_test.go
@@
-81,6
+81,13
@@
func TestGetHandler(t *testing.T) {
"Unauthenticated request, unsigned locator",
string(TEST_BLOCK),
response)
"Unauthenticated request, unsigned locator",
string(TEST_BLOCK),
response)
+
+ received_cl := response.Header().Get("Content-Length")
+ expected_cl := fmt.Sprintf("%d", len(TEST_BLOCK))
+ if received_cl != expected_cl {
+ t.Errorf("expected Content-Length %s, got %s", expected_cl, received_cl)
+ }
+
received_xbs := response.Header().Get("X-Block-Size")
expected_xbs := fmt.Sprintf("%d", len(TEST_BLOCK))
if received_xbs != expected_xbs {
received_xbs := response.Header().Get("X-Block-Size")
expected_xbs := fmt.Sprintf("%d", len(TEST_BLOCK))
if received_xbs != expected_xbs {
@@
-102,12
+109,19
@@
func TestGetHandler(t *testing.T) {
"Authenticated request, signed locator", http.StatusOK, response)
ExpectBody(t,
"Authenticated request, signed locator", string(TEST_BLOCK), response)
"Authenticated request, signed locator", http.StatusOK, response)
ExpectBody(t,
"Authenticated request, signed locator", string(TEST_BLOCK), response)
+
received_xbs = response.Header().Get("X-Block-Size")
expected_xbs = fmt.Sprintf("%d", len(TEST_BLOCK))
if received_xbs != expected_xbs {
t.Errorf("expected X-Block-Size %s, got %s", expected_xbs, received_xbs)
}
received_xbs = response.Header().Get("X-Block-Size")
expected_xbs = fmt.Sprintf("%d", len(TEST_BLOCK))
if received_xbs != expected_xbs {
t.Errorf("expected X-Block-Size %s, got %s", expected_xbs, received_xbs)
}
+ received_cl = response.Header().Get("Content-Length")
+ expected_cl = fmt.Sprintf("%d", len(TEST_BLOCK))
+ if received_cl != expected_cl {
+ t.Errorf("expected Content-Length %s, got %s", expected_cl, received_cl)
+ }
+
// Authenticated request, unsigned locator
// => PermissionError
response = IssueRequest(&RequestTester{
// Authenticated request, unsigned locator
// => PermissionError
response = IssueRequest(&RequestTester{
@@
-276,10
+290,10
@@
func TestIndexHandler(t *testing.T) {
// -------------------------------------------------------------
// Only the superuser should be allowed to issue /index requests.
// -------------------------------------------------------------
// Only the superuser should be allowed to issue /index requests.
- // ---------------------------
- // enforce_permissions enabled
+
// ---------------------------
+
// enforce_permissions enabled
// This setting should not affect tests passing.
// This setting should not affect tests passing.
- enforce_permissions = true
+
enforce_permissions = true
// unauthenticated /index request
// => UnauthorizedError
// unauthenticated /index request
// => UnauthorizedError
@@
-334,8
+348,6
@@
func TestIndexHandler(t *testing.T) {
http.StatusOK,
response)
http.StatusOK,
response)
-
-
expected := `^` + TEST_HASH + `\+\d+ \d+\n` +
TEST_HASH_2 + `\+\d+ \d+\n$`
match, _ := regexp.MatchString(expected, response.Body.String())
expected := `^` + TEST_HASH + `\+\d+ \d+\n` +
TEST_HASH_2 + `\+\d+ \d+\n$`
match, _ := regexp.MatchString(expected, response.Body.String())
@@
-731,8
+743,8
@@
func IssueRequest(rt *RequestTester) *httptest.ResponseRecorder {
if rt.api_token != "" {
req.Header.Set("Authorization", "OAuth2 "+rt.api_token)
}
if rt.api_token != "" {
req.Header.Set("Authorization", "OAuth2 "+rt.api_token)
}
-
routerWrapper := MakeRESTRouterWrapp
er()
-
routerWrapp
er.ServeHTTP(response, req)
+
loggingRouter := MakeLoggingRESTRout
er()
+
loggingRout
er.ServeHTTP(response, req)
return response
}
return response
}