1.重构认证方式的代码,方便未来扩展 2.补充测试用例

This commit is contained in:
lanrenwo
2022-06-06 21:25:19 +08:00
parent c38f1e9b8c
commit b06c035cce
6 changed files with 149 additions and 76 deletions

View File

@@ -24,8 +24,25 @@ func TestGetGroupNames(t *testing.T) {
err = SetGroup(&g3)
ast.Nil(err)
authData := map[string]interface{}{
"type": "radius",
"radius": map[string]string{
"addr": "192.168.8.12:1044",
"secret": "43214132",
},
}
g4 := Group{Name: "g4", ClientDns: []ValData{{Val: "114.114.114.114"}}, Auth: authData}
err = SetGroup(&g4)
ast.Nil(err)
g5 := Group{Name: "g5", ClientDns: []ValData{{Val: "114.114.114.114"}}, DsIncludeDomains: "baidu.com,163.com"}
err = SetGroup(&g5)
ast.Nil(err)
g6 := Group{Name: "g6", ClientDns: []ValData{{Val: "114.114.114.114"}}, DsExcludeDomains: "com.cn,qq.com"}
err = SetGroup(&g6)
ast.Nil(err)
// 判断所有数据
gAll := []string{"g1", "g2", "g3"}
gAll := []string{"g1", "g2", "g3", "g4", "g5", "g6"}
gs := GetGroupNames()
for _, v := range gs {
ast.Equal(true, utils.InArrStr(gAll, v))