59 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package secret
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestCodetInfo(t *testing.T) {
 | |
| 
 | |
| 	if GetPositionCode("鉴证科") != "jzk" {
 | |
| 		t.Errorf("验证错误 ")
 | |
| 	}
 | |
| 
 | |
| 	if GetPositionCode("鉴证科1") == "jzk" {
 | |
| 		t.Errorf("验证错误 ")
 | |
| 	}
 | |
| 
 | |
| }
 | |
| 
 | |
| func TestSecretInfo(t *testing.T) {
 | |
| 	token := "abc"
 | |
| 	position := "pppp"
 | |
| 	name := "王德发"
 | |
| 	str, err := CombineSecret(position, name, token)
 | |
| 	if err != nil {
 | |
| 		t.Errorf("组合加密错误 %s", err.Error())
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	t.Logf("加密之后 %s", str)
 | |
| 
 | |
| 	tokenExample, err := GetJwtFromStr(str)
 | |
| 	if err != nil {
 | |
| 		t.Errorf("获取token组合加密错误 %s", err.Error())
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	if tokenExample != token {
 | |
| 		t.Errorf("解密不符合 %s", "解析内容不匹配")
 | |
| 	}
 | |
| 
 | |
| 	t.Logf("加解密通过 %s", tokenExample)
 | |
| 
 | |
| }
 | |
| 
 | |
| func TestCommonCombineSecret(t *testing.T) {
 | |
| 	a := "zzzz"
 | |
| 	str, err := CommonCombineSecret(a)
 | |
| 	if err != nil {
 | |
| 		t.Errorf("组合加密错误 %s", err.Error())
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	t.Logf("加密之后 %s", str)
 | |
| 
 | |
| 	tokenExample, err := CommonDec(str)
 | |
| 	fmt.Println(tokenExample, err)
 | |
| }
 |