fix: align with encoding v1.5.2 (by AI)
This commit is contained in:
parent
b2364194b1
commit
a5339d98d5
@ -83,7 +83,7 @@ func TestBuiltinSigners(t *testing.T) {
|
|||||||
if err := signer.Sign(req, config); err != nil {
|
if err := signer.Sign(req, config); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
expected := "Basic " + encoding.Base64ToString([]byte("admin:123"))
|
expected := "Basic " + encoding.Base64([]byte("admin:123"))
|
||||||
if req.GetHeader("Authorization") != expected {
|
if req.GetHeader("Authorization") != expected {
|
||||||
t.Errorf("expected %s, got %s", expected, req.GetHeader("Authorization"))
|
t.Errorf("expected %s, got %s", expected, req.GetHeader("Authorization"))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -218,8 +218,8 @@ func decryptMapWithPrefix(m map[string]any) []*safe.SafeBuf {
|
|||||||
raw := s[2:]
|
raw := s[2:]
|
||||||
var b64 []byte
|
var b64 []byte
|
||||||
var err error
|
var err error
|
||||||
if b64, err = encoding.UnUrlBase64FromString(raw); err != nil {
|
if b64, err = encoding.UnURLBase64(raw); err != nil {
|
||||||
b64, err = encoding.UnBase64FromString(raw)
|
b64, err = encoding.UnBase64(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && len(b64) > 0 {
|
if err == nil && len(b64) > 0 {
|
||||||
@ -249,8 +249,8 @@ func decryptMap(m map[string]any) []*safe.SafeBuf {
|
|||||||
inner = s[4 : len(s)-1]
|
inner = s[4 : len(s)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
if b64, err = encoding.UnUrlBase64FromString(inner); err != nil {
|
if b64, err = encoding.UnURLBase64(inner); err != nil {
|
||||||
b64, err = encoding.UnBase64FromString(inner)
|
b64, err = encoding.UnBase64(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && len(b64) > 0 {
|
if err == nil && len(b64) > 0 {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ func TestSafeConfigDecryption(t *testing.T) {
|
|||||||
|
|
||||||
plaintext := "my-secret-password"
|
plaintext := "my-secret-password"
|
||||||
ciphertext, _ := confAES.EncryptBytes([]byte(plaintext))
|
ciphertext, _ := confAES.EncryptBytes([]byte(plaintext))
|
||||||
b64 := encoding.Base64ToString(ciphertext)
|
b64 := encoding.Base64(ciphertext)
|
||||||
|
|
||||||
GlobalConfigs = map[string]any{
|
GlobalConfigs = map[string]any{
|
||||||
"api": map[string]any{
|
"api": map[string]any{
|
||||||
@ -51,7 +51,7 @@ func TestSafeConfigDecryption(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedAuth := "Basic " + encoding.Base64ToString([]byte("admin:"+plaintext))
|
expectedAuth := "Basic " + encoding.Base64([]byte("admin:"+plaintext))
|
||||||
if req.GetHeader("Authorization") != expectedAuth {
|
if req.GetHeader("Authorization") != expectedAuth {
|
||||||
t.Errorf("expected %s, got %s", expectedAuth, req.GetHeader("Authorization"))
|
t.Errorf("expected %s, got %s", expectedAuth, req.GetHeader("Authorization"))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user