remove dependency to external base62 package and create own methods in utils

This commit is contained in:
Pascal Fischer
2023-05-16 12:44:26 +02:00
parent a3ee45b79e
commit 2fef52b856
7 changed files with 101 additions and 9 deletions
@@ -4,11 +4,13 @@ import (
"crypto/sha256"
b64 "encoding/base64"
"hash/crc32"
"math/big"
"strings"
"testing"
"codeberg.org/ac/base62"
"github.com/stretchr/testify/assert"
"github.com/netbirdio/netbird/util"
)
func TestPAT_GenerateToken_Hashing(t *testing.T) {
@@ -33,8 +35,10 @@ func TestPAT_GenerateToken_Checksum(t *testing.T) {
secret := tokenWithoutPrefix[:len(tokenWithoutPrefix)-6]
tokenCheckSum := tokenWithoutPrefix[len(tokenWithoutPrefix)-6:]
var i big.Int
i.SetString(secret, 62)
expectedChecksum := crc32.ChecksumIEEE([]byte(secret))
actualChecksum, err := base62.Decode(tokenCheckSum)
actualChecksum, err := util.DecodeBase62(tokenCheckSum)
if err != nil {
t.Fatal(err)
}