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.

sanitize_test.go 884B

12345678910111213141516171819202122232425
  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 util
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestSanitizeURLCredentials(t *testing.T) {
  10. var kases = map[string]string{
  11. "https://github.com/go-gitea/test_repo.git": "https://github.com/go-gitea/test_repo.git",
  12. "https://mytoken@github.com/go-gitea/test_repo.git": "https://github.com/go-gitea/test_repo.git",
  13. "http://github.com/go-gitea/test_repo.git": "http://github.com/go-gitea/test_repo.git",
  14. "/test/repos/repo1": "/test/repos/repo1",
  15. "git@github.com:go-gitea/test_repo.git": "(unparsable url)",
  16. }
  17. for source, value := range kases {
  18. assert.EqualValues(t, value, SanitizeURLCredentials(source, false))
  19. }
  20. }