- TestDecrypt
This commit is contained in:
@@ -181,6 +181,7 @@ func (a *API) GetCallbackMsg(formMap map[string]interface{}, bodyData []byte) (m
|
|||||||
} else {
|
} else {
|
||||||
var descryptMsg string
|
var descryptMsg string
|
||||||
if descryptMsg, err = a.Decrypt(encrypt); err == nil {
|
if descryptMsg, err = a.Decrypt(encrypt); err == nil {
|
||||||
|
baseapi.SugarLogger.Debugf("dingding GetCallbackMsg descryptMsg:%s", descryptMsg)
|
||||||
err = utils.UnmarshalUseNumber([]byte(descryptMsg), &msgMap)
|
err = utils.UnmarshalUseNumber([]byte(descryptMsg), &msgMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,29 @@
|
|||||||
package dingdingapi
|
package dingdingapi
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
func TestEncrypt(t *testing.T) {
|
"git.rosy.net.cn/baseapi"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCrypt(t *testing.T) {
|
||||||
api.RegisterCallback(nil, "token", "M3Z1b1FIXjlAWW84bEVxNENHSlZOUFJEbkAlRUZQXnE", "")
|
api.RegisterCallback(nil, "token", "M3Z1b1FIXjlAWW84bEVxNENHSlZOUFJEbkAlRUZQXnE", "")
|
||||||
encryptedMsg, err := api.Encrypt("hello")
|
encryptedMsg, err := api.Encrypt("hello")
|
||||||
decryptedMsg, err := api.Decrypt(encryptedMsg)
|
decryptedMsg, err := api.Decrypt(encryptedMsg)
|
||||||
t.Log(encryptedMsg, decryptedMsg, err)
|
t.Log(encryptedMsg, decryptedMsg, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDecrypt(t *testing.T) {
|
||||||
|
api.RegisterCallback(nil, "j9JMGyaZs&vxqt&S", "VFFjTnZrZDJZZmZHJksxeTlxcnp5aG42WmRCbXl3REE", "")
|
||||||
|
encryptedMsg := "UsgVSPqyJg1aLBmVSbAP19AcIgK/O2UgOfo7lOuwRbSfPDP8XnDUuE+os+nnxsbaMTJ4DSu/twE5aNrZk7RDE9vZYiT/gXqXNvj7y45R32xfOLecVNTvy13wF4vDzuUB"
|
||||||
|
decryptedMsg, err := api.Decrypt(encryptedMsg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else {
|
||||||
|
baseapi.SugarLogger.Debugf("decryptedMsg:%s\n", decryptedMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPackCallbackResult(t *testing.T) {
|
func TestPackCallbackResult(t *testing.T) {
|
||||||
api.RegisterCallback(nil, "token", "M3Z1b1FIXjlAWW84bEVxNENHSlZOUFJEbkAlRUZQXnE", "")
|
api.RegisterCallback(nil, "token", "M3Z1b1FIXjlAWW84bEVxNENHSlZOUFJEbkAlRUZQXnE", "")
|
||||||
success := api.PackCallbackResult("success")
|
success := api.PackCallbackResult("success")
|
||||||
|
|||||||
Reference in New Issue
Block a user