1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Remove deprecated packages & staticcheck fixes (#22012)

`ioutil` is deprecated and should use `io` instead
This commit is contained in:
Chongyi Zheng
2022-12-02 17:06:23 -05:00
committed by GitHub
parent 21bcb92926
commit 8698458f48
7 changed files with 15 additions and 16 deletions

View File

@@ -34,9 +34,9 @@ func TestDownloadByIDForSVGUsesSecureHeaders(t *testing.T) {
req := NewRequest(t, "GET", "/user2/repo2/raw/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
resp := session.MakeRequest(t, req, http.StatusOK)
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.Header().Get("Content-Security-Policy"))
assert.Equal(t, "image/svg+xml", resp.Header().Get("Content-Type"))
assert.Equal(t, "nosniff", resp.Header().Get("X-Content-Type-Options"))
}
func TestDownloadByIDMedia(t *testing.T) {
@@ -60,9 +60,9 @@ func TestDownloadByIDMediaForSVGUsesSecureHeaders(t *testing.T) {
req := NewRequest(t, "GET", "/user2/repo2/media/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
resp := session.MakeRequest(t, req, http.StatusOK)
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.Header().Get("Content-Security-Policy"))
assert.Equal(t, "image/svg+xml", resp.Header().Get("Content-Type"))
assert.Equal(t, "nosniff", resp.Header().Get("X-Content-Type-Options"))
}
func TestDownloadRawTextFileWithoutMimeTypeMapping(t *testing.T) {
@@ -73,7 +73,7 @@ func TestDownloadRawTextFileWithoutMimeTypeMapping(t *testing.T) {
req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml")
resp := session.MakeRequest(t, req, http.StatusOK)
assert.Equal(t, "text/plain; charset=utf-8", resp.HeaderMap.Get("Content-Type"))
assert.Equal(t, "text/plain; charset=utf-8", resp.Header().Get("Content-Type"))
}
func TestDownloadRawTextFileWithMimeTypeMapping(t *testing.T) {
@@ -86,7 +86,7 @@ func TestDownloadRawTextFileWithMimeTypeMapping(t *testing.T) {
req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml")
resp := session.MakeRequest(t, req, http.StatusOK)
assert.Equal(t, "text/xml; charset=utf-8", resp.HeaderMap.Get("Content-Type"))
assert.Equal(t, "text/xml; charset=utf-8", resp.Header().Get("Content-Type"))
delete(setting.MimeTypeMap.Map, ".xml")
setting.MimeTypeMap.Enabled = false