Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/activitypub/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestActivityPubSignedPost(t *testing.T) {
body, err := io.ReadAll(r.Body)
assert.NoError(t, err)
assert.Equal(t, expected, string(body))
fmt.Fprintf(w, expected)
fmt.Fprintln(w, expected)
}))
defer srv.Close()

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/api_packages_nuget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -106,7 +105,7 @@ func TestPackageNuGet(t *testing.T) {
return &buf
}

content, _ := ioutil.ReadAll(createPackage(packageName, packageVersion))
content, _ := io.ReadAll(createPackage(packageName, packageVersion))

url := fmt.Sprintf("/api/packages/%s/nuget", user.Name)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api_packages_vagrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestPackageVagrant(t *testing.T) {

req = NewRequest(t, "HEAD", boxURL)
resp := MakeRequest(t, req, http.StatusOK)
assert.True(t, strings.HasPrefix(resp.HeaderMap.Get("Content-Type"), "application/json"))
assert.True(t, strings.HasPrefix(resp.Header().Get("Content-Type"), "application/json"))

pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeVagrant)
assert.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/api_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package integration

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -41,7 +41,7 @@ func TestAPIViewPulls(t *testing.T) {
pull := pulls[0]
if assert.EqualValues(t, 5, pull.ID) {
resp = ctx.Session.MakeRequest(t, NewRequest(t, "GET", pull.DiffURL), http.StatusOK)
_, err := ioutil.ReadAll(resp.Body)
_, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
// TODO: use diff to generate stats to test against

Expand Down
16 changes: 8 additions & 8 deletions tests/integration/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,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) {
Expand All @@ -61,9 +61,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) {
Expand All @@ -74,7 +74,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) {
Expand All @@ -87,7 +87,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
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/nonascii_branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func testSrcRouteRedirect(t *testing.T, session *TestSession, user, repo, route,
resp := session.MakeRequest(t, req, http.StatusSeeOther)

// Check Location header
location := resp.HeaderMap.Get("Location")
location := resp.Header().Get("Location")
assert.Equal(t, path.Join(prefix, expectedLocation), location)

// Perform redirect
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rename_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestRenameBranch(t *testing.T) {
// check old branch link
req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/master/README.md", postData)
resp = session.MakeRequest(t, req, http.StatusSeeOther)
location := resp.HeaderMap.Get("Location")
location := resp.Header().Get("Location")
assert.Equal(t, "/user2/repo1/src/branch/main/README.md", location)

// check db
Expand Down