You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

view_test.go 727B

123456789101112131415161718192021222324252627
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package integration
  4. import (
  5. "net/http"
  6. "testing"
  7. "code.gitea.io/gitea/tests"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestRenderFileSVGIsInImgTag(t *testing.T) {
  11. defer tests.PrepareTestEnv(t)()
  12. session := loginUser(t, "user2")
  13. req := NewRequest(t, "GET", "/user2/repo2/src/branch/master/line.svg")
  14. resp := session.MakeRequest(t, req, http.StatusOK)
  15. doc := NewHTMLParser(t, resp.Body)
  16. src, exists := doc.doc.Find(".file-view img").Attr("src")
  17. assert.True(t, exists, "The SVG image should be in an <img> tag so that scripts in the SVG are not run")
  18. assert.Equal(t, "/user2/repo2/raw/branch/master/line.svg", src)
  19. }