mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-02 22:10:26 +08:00
37 lines
890 B
Go
37 lines
890 B
Go
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
|
|
|
|
package dnsclients_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
|
|
"github.com/iwind/TeaGo/assert"
|
|
)
|
|
|
|
func TestIsMasked(t *testing.T) {
|
|
var a = assert.NewAssertion(t)
|
|
a.IsFalse(dnsclients.IsMasked(""))
|
|
a.IsFalse(dnsclients.IsMasked("abc"))
|
|
a.IsFalse(dnsclients.IsMasked("abc*"))
|
|
a.IsTrue(dnsclients.IsMasked("*"))
|
|
a.IsTrue(dnsclients.IsMasked("**"))
|
|
a.IsTrue(dnsclients.IsMasked("***"))
|
|
a.IsTrue(dnsclients.IsMasked("*******"))
|
|
a.IsTrue(dnsclients.IsMasked("abc**"))
|
|
a.IsTrue(dnsclients.IsMasked("abcd*********"))
|
|
}
|
|
|
|
func TestUnmaskAPIParams(t *testing.T) {
|
|
data, err := dnsclients.UnmaskAPIParams([]byte(`{
|
|
"key": "a",
|
|
"secret": "abc12"
|
|
}`), []byte(`{
|
|
"secret": "abc**"
|
|
}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(string(data))
|
|
}
|