Commit 9b0f780a authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

renamed some files

parent 1e301cb4
...@@ -76,7 +76,7 @@ test: ...@@ -76,7 +76,7 @@ test:
command: ['server', '/minio'] command: ['server', '/minio']
alias: minio alias: minio
before_script: before_script:
- wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/bin/mc && chmod +x /usr/bin/mc - wget -qO /usr/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && chmod +x /usr/bin/mc
- mc alias set gitlab http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD} - mc alias set gitlab http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
- mc mb gitlab/${S3_BUCKET} - mc mb gitlab/${S3_BUCKET}
script: script:
......
...@@ -171,25 +171,37 @@ func TestEndpoint(router *gin.Engine, token string, url string, ...@@ -171,25 +171,37 @@ func TestEndpoint(router *gin.Engine, token string, url string,
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer "+token) req.Header.Add("Authorization", "Bearer "+token)
const maxRedirCount = 10 router.ServeHTTP(w, req)
var redirCount int
for redirCount = 0; redirCount < maxRedirCount; redirCount++ { return handleRedirect(w, req)
router.ServeHTTP(w, req) }
if w.Code == 301 || w.Code == 302 || w.Code == 307 || w.Code == 308 { func handleRedirect(w *httptest.ResponseRecorder, req *http.Request) (int, *bytes.Buffer, error) {
req.URL, err = w.Result().Location() if w.Code == http.StatusMovedPermanently ||
if err != nil { w.Code == http.StatusFound ||
return 0, nil, fmt.Errorf("Invalid location header") w.Code == http.StatusTemporaryRedirect ||
} w.Code == http.StatusPermanentRedirect {
} else {
break // Follow external redirect
var err error
req.URL, err = w.Result().Location()
if err != nil {
return 0, nil, fmt.Errorf("Invalid location header")
} }
}
if redirCount == maxRedirCount { client := &http.Client{}
return 0, nil, fmt.Errorf("Max redirection count exceeded") resp, err := client.Do(req)
if err != nil {
return 0, nil, fmt.Errorf("Failed to follow redirect: %v", err)
}
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
return resp.StatusCode, buf, nil
} }
// No redirect
return w.Code, w.Body, nil return w.Code, w.Body, nil
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment