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 764B

1234567891011121314151617181920212223242526
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestRenderFileSVGIsInImgTag(t *testing.T) {
  11. defer 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. }