1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package test
- import (
- "encoding/json"
- "eta/eta_mini_ht_api/common/utils/auth"
- "eta/eta_mini_ht_api/controllers/web_hook"
- "testing"
- "time"
- )
- func TestEncryptWithRSA(t *testing.T) {
- type args struct {
- data interface{}
- }
- tests := []struct {
- name string
- args args
- }{
- {
- name: "test",
- args: args{
- data: web_hook.AccountOpenInfoReq{
- MobileTel: "18267183251",
- //DealMobileTel string `json:"deal_mobile_tel"`
- ClientName: "陈晗",
- IdKind: 1,
- IdNo: "330501199101080013",
- AccountStatus: "failed",
- //ErrorCode int `json:"error_code"`
- IdBeginDate: "2021-03-10",
- IdEndDate: "2029-03-10",
- ErrorMessage: "不合法的开户请求",
- Timestamp: time.Now().Unix(),
- },
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- pk, _ := auth.ParsePublicKeyFromPEM()
- bytes, _ := json.Marshal(tt.args.data)
- entry, _ := auth.EncryptWithRSA(pk, bytes)
- //fmt.Println(string(entry))
- got, _ := auth.EncryptWithRSA(pk, entry)
- t.Errorf("EncryptWithRSA() got = %v, ", got)
- //if (err != nil) != tt.wantErr {
- // t.Errorf("EncryptWithRSA() error = %v, wantErr %v", err, tt.wantErr)
- // return
- //}
- //if !reflect.DeepEqual(got, tt.want) {
- // t.Errorf("EncryptWithRSA() got = %v, want %v", got, tt.want)
- //}
- //fmt.Println(got)
- })
- }
- }
|