-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
403を返した場合もクライアントには403を返すようにします #11
Conversation
@@ -87,7 +87,7 @@ func proxy(w http.ResponseWriter, r *http.Request) { | |||
orgRes, err = client.Do(req) | |||
} | |||
|
|||
if err != nil || orgRes.StatusCode == http.StatusNotFound { | |||
if err != nil || orgRes.StatusCode == http.StatusNotFound || orgRes.StatusCode == http.StatusForbidden { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
403 forbidden をエラーにしない。
func TestOriginForbidden(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(proxy)) | ||
|
||
origin := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
http.Error(w, "403 Forbidden", http.StatusForbidden) | ||
})) | ||
|
||
orgSrvURL = origin.URL | ||
|
||
url := ts.URL + "/forbidden.jpg" | ||
|
||
res, err := http.Get(url) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if res.StatusCode != http.StatusForbidden { | ||
t.Errorf("HTTP status is %d, want %d", res.StatusCode, http.StatusNotFound) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
403 forbidden のレスポンスが正しく処理されることのテスト。
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestOriginForbidden$ github.com/pepabo/oyaki
=== RUN TestOriginForbidden
2023/12/01 13:09:43 Get origin failed. <nil>
--- PASS: TestOriginForbidden (0.00s)
PASS
ok github.com/pepabo/oyaki (cached)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそうだと思いました!
No description provided.