forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shadow the password on cache and session config on admin panel (go-gi…
…tea#7300) * shadow the password on cache and session config on admin panel * add shadow password of mysql/postgres/couchbase * fix log import
- Loading branch information
Showing
2 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2019 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 admin | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestShadowPassword(t *testing.T) { | ||
var kases = []struct { | ||
Provider string | ||
CfgItem string | ||
Result string | ||
}{ | ||
{ | ||
Provider: "redis", | ||
CfgItem: "network=tcp,addr=:6379,password=gitea,db=0,pool_size=100,idle_timeout=180", | ||
Result: "network=tcp,addr=:6379,password=******,db=0,pool_size=100,idle_timeout=180", | ||
}, | ||
{ | ||
Provider: "mysql", | ||
CfgItem: "root:@tcp(localhost:3306)/gitea?charset=utf8", | ||
Result: "root:******@tcp(localhost:3306)/gitea?charset=utf8", | ||
}, | ||
{ | ||
Provider: "mysql", | ||
CfgItem: "/gitea?charset=utf8", | ||
Result: "/gitea?charset=utf8", | ||
}, | ||
{ | ||
Provider: "mysql", | ||
CfgItem: "user:mypassword@/dbname", | ||
Result: "user:******@/dbname", | ||
}, | ||
{ | ||
Provider: "postgres", | ||
CfgItem: "user=pqgotest dbname=pqgotest sslmode=verify-full", | ||
Result: "user=pqgotest dbname=pqgotest sslmode=verify-full", | ||
}, | ||
{ | ||
Provider: "postgres", | ||
CfgItem: "user=pqgotest password= dbname=pqgotest sslmode=verify-full", | ||
Result: "user=pqgotest password=****** dbname=pqgotest sslmode=verify-full", | ||
}, | ||
{ | ||
Provider: "postgres", | ||
CfgItem: "postgres://user:pass@hostname/dbname", | ||
Result: "postgres://user:******@hostname/dbname", | ||
}, | ||
{ | ||
Provider: "couchbase", | ||
CfgItem: "http://dev-couchbase.example.com:8091/", | ||
Result: "http://dev-couchbase.example.com:8091/", | ||
}, | ||
{ | ||
Provider: "couchbase", | ||
CfgItem: "http://user:[email protected]:8091/", | ||
Result: "http://user:******@dev-couchbase.example.com:8091/", | ||
}, | ||
} | ||
|
||
for _, k := range kases { | ||
assert.EqualValues(t, k.Result, shadowPassword(k.Provider, k.CfgItem)) | ||
} | ||
} |