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.

32 lines
948 B

  1. // Copyright 2017 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. "code.gitea.io/gitea/models"
  9. )
  10. func TestAPIReposRaw(t *testing.T) {
  11. defer prepareTestEnv(t)()
  12. user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
  13. // Login as User2.
  14. session := loginUser(t, user.Name)
  15. token := getTokenForLoggedInUser(t, session)
  16. for _, ref := range [...]string{
  17. "master", // Branch
  18. "v1.1", // Tag
  19. "65f1bf27bc3bf70f64657658635e66094edbcb4d", // Commit
  20. } {
  21. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md?token="+token, user.Name, ref)
  22. session.MakeRequest(t, req, http.StatusOK)
  23. }
  24. // Test default branch
  25. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md?token="+token, user.Name)
  26. session.MakeRequest(t, req, http.StatusOK)
  27. }