mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-29 03:20:24 +08:00
数据库节点密码支持加密存储
This commit is contained in:
@@ -2,4 +2,42 @@ package models
|
||||
|
||||
import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDBNodeDAO_EncodePassword(t *testing.T) {
|
||||
dao := NewDBNodeDAO()
|
||||
for _, password := range []string{
|
||||
"123456",
|
||||
"abcdefxyz",
|
||||
"123abc$*&^%",
|
||||
"$%#@!@(*))*&^&=]{|",
|
||||
"中文",
|
||||
} {
|
||||
encoded := dao.EncodePassword(password)
|
||||
decoded := dao.DecodePassword(encoded)
|
||||
if decoded != password {
|
||||
t.Fatal(decoded, password)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDBNodeDAO_EncodePassword_Encoded(t *testing.T) {
|
||||
dao := NewDBNodeDAO()
|
||||
password := DBNodePasswordEncodedPrefix + "123456"
|
||||
encoded := dao.EncodePassword(password)
|
||||
if encoded != password {
|
||||
t.Fatal()
|
||||
}
|
||||
t.Log(encoded)
|
||||
}
|
||||
|
||||
func TestDBNodeDAO_EncodePassword_Decoded(t *testing.T) {
|
||||
dao := NewDBNodeDAO()
|
||||
password := "123456"
|
||||
decoded := dao.DecodePassword(password)
|
||||
if decoded != password {
|
||||
t.Fatal()
|
||||
}
|
||||
t.Log(decoded)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user