+ for _, trial := range []struct {
+ label string
+ method string
+ token string
+ xKeepSignature string
+ expectRemoteReqs int64
+ expectCode int
+ expectSignature bool
+ }{
+ {
+ label: "GET only",
+ method: "GET",
+ token: arvadostest.ActiveTokenV2,
+ expectRemoteReqs: 1,
+ expectCode: http.StatusOK,
+ },
+ {
+ label: "obsolete token",
+ method: "GET",
+ token: arvadostest.ActiveToken,
+ expectRemoteReqs: 0,
+ expectCode: http.StatusBadRequest,
+ },
+ {
+ label: "bad token",
+ method: "GET",
+ token: arvadostest.ActiveTokenV2[:len(arvadostest.ActiveTokenV2)-3] + "xxx",
+ expectRemoteReqs: 1,
+ expectCode: http.StatusNotFound,
+ },
+ {
+ label: "HEAD only",
+ method: "HEAD",
+ token: arvadostest.ActiveTokenV2,
+ expectRemoteReqs: 1,
+ expectCode: http.StatusOK,
+ },
+ {
+ label: "HEAD with local signature",
+ method: "HEAD",
+ xKeepSignature: "local, time=" + time.Now().Format(time.RFC3339),
+ token: arvadostest.ActiveTokenV2,
+ expectRemoteReqs: 1,
+ expectCode: http.StatusOK,
+ expectSignature: true,
+ },
+ {
+ label: "GET with local signature",
+ method: "GET",
+ xKeepSignature: "local, time=" + time.Now().Format(time.RFC3339),
+ token: arvadostest.ActiveTokenV2,
+ expectRemoteReqs: 1,
+ expectCode: http.StatusOK,
+ expectSignature: true,
+ },
+ } {
+ c.Logf("trial: %s", trial.label)
+
+ s.remoteKeepRequests = 0
+
+ var req *http.Request
+ var resp *httptest.ResponseRecorder
+ req = httptest.NewRequest(trial.method, path, nil)
+ req.Header.Set("Authorization", "Bearer "+trial.token)
+ if trial.xKeepSignature != "" {
+ req.Header.Set("X-Keep-Signature", trial.xKeepSignature)
+ }