3 Star 0 Fork 1

tym_hmm/mongo-tool

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
strings_test.go 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
天蝎儿 提交于 2021-11-03 19:30 +08:00 . 修改模块名称
package util
import (
"testing"
"gitee.com/tym_hmm/mongo-tool/common/testtype"
)
func TestSanitizeURI(t *testing.T) {
testtype.SkipUnlessTestType(t, testtype.UnitTestType)
cases := [][]string{
{"mongodb://example.com/", "mongodb://example.com/"},
{"mongodb://example.com/?appName=foo:@bar", "mongodb://example.com/?appName=foo:@bar"},
{"mongodb://example.com?appName=foo:@bar", "mongodb://example.com?appName=foo:@bar"},
{"mongodb://@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb://:@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb://user@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb://user:@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb://:pass@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb://user:pass@example.com/", "mongodb://[**REDACTED**]@example.com/"},
{"mongodb+srv://example.com/", "mongodb+srv://example.com/"},
{"mongodb+srv://@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
{"mongodb+srv://:@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
{"mongodb+srv://user@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
{"mongodb+srv://user:@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
{"mongodb+srv://:pass@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
{"mongodb+srv://user:pass@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"},
}
for _, c := range cases {
got := SanitizeURI(c[0])
if got != c[1] {
t.Errorf("For %s: got: %s; wanted: %s", c[0], got, c[1])
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tym_hmm/mongo-tool.git
git@gitee.com:tym_hmm/mongo-tool.git
tym_hmm
mongo-tool
mongo-tool
v1.0.5

搜索帮助