summaryrefslogtreecommitdiffstats
path: root/modules/util/sanitize_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-25 18:57:43 +0800
committerzeripath <art27@cantab.net>2020-01-25 10:57:42 +0000
commita67c06ce90fb3bea97987501377e4dc5f24d2151 (patch)
tree40de3d2b2de625f44529859ec4fc642ab8d31f21 /modules/util/sanitize_test.go
parent5b17bb8f3dbc180c72446000d82ba06fd7349dc7 (diff)
downloadgitea-a67c06ce90fb3bea97987501377e4dc5f24d2151.tar.gz
gitea-a67c06ce90fb3bea97987501377e4dc5f24d2151.zip
Sanitize credentials in mirror form (#9975)
Diffstat (limited to 'modules/util/sanitize_test.go')
-rw-r--r--modules/util/sanitize_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/util/sanitize_test.go b/modules/util/sanitize_test.go
new file mode 100644
index 0000000000..4f07100675
--- /dev/null
+++ b/modules/util/sanitize_test.go
@@ -0,0 +1,25 @@
+// Copyright 2020 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package util
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSanitizeURLCredentials(t *testing.T) {
+ var kases = map[string]string{
+ "https://github.com/go-gitea/test_repo.git": "https://github.com/go-gitea/test_repo.git",
+ "https://mytoken@github.com/go-gitea/test_repo.git": "https://github.com/go-gitea/test_repo.git",
+ "http://github.com/go-gitea/test_repo.git": "http://github.com/go-gitea/test_repo.git",
+ "/test/repos/repo1": "/test/repos/repo1",
+ "git@github.com:go-gitea/test_repo.git": "(unparsable url)",
+ }
+
+ for source, value := range kases {
+ assert.EqualValues(t, value, SanitizeURLCredentials(source, false))
+ }
+}