mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-30 14:25:06 +02:00
fixed some namings
This commit is contained in:
parent
2f2d45de9e
commit
95d87384ab
@ -32,7 +32,7 @@ func CreateNewPAT(description string, expirationInDays int, createdBy string) (*
|
|||||||
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
|
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
|
||||||
CreatedBy: createdBy,
|
CreatedBy: createdBy,
|
||||||
CreatedAt: currentTime,
|
CreatedAt: currentTime,
|
||||||
LastUsed: currentTime, // using creation time as nil not possible
|
LastUsed: currentTime,
|
||||||
}, plainToken
|
}, plainToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ func TestPAT_GenerateToken_Hashing(t *testing.T) {
|
|||||||
|
|
||||||
func TestPAT_GenerateToken_Prefix(t *testing.T) {
|
func TestPAT_GenerateToken_Prefix(t *testing.T) {
|
||||||
_, plainToken := generateNewToken()
|
_, plainToken := generateNewToken()
|
||||||
fourLetterPrefix := plainToken[:4]
|
fourCharPrefix := plainToken[:4]
|
||||||
assert.Equal(t, "nbp_", fourLetterPrefix)
|
assert.Equal(t, "nbp_", fourCharPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPAT_GenerateToken_Checksum(t *testing.T) {
|
func TestPAT_GenerateToken_Checksum(t *testing.T) {
|
||||||
@ -28,10 +28,10 @@ func TestPAT_GenerateToken_Checksum(t *testing.T) {
|
|||||||
if len(tokenWithoutPrefix) != 36 {
|
if len(tokenWithoutPrefix) != 36 {
|
||||||
t.Fatal("Token has wrong length")
|
t.Fatal("Token has wrong length")
|
||||||
}
|
}
|
||||||
token := tokenWithoutPrefix[:len(tokenWithoutPrefix)-6]
|
secret := tokenWithoutPrefix[:len(tokenWithoutPrefix)-6]
|
||||||
tokenCheckSum := tokenWithoutPrefix[len(tokenWithoutPrefix)-6:]
|
tokenCheckSum := tokenWithoutPrefix[len(tokenWithoutPrefix)-6:]
|
||||||
|
|
||||||
expectedChecksum := crc32.ChecksumIEEE([]byte(token))
|
expectedChecksum := crc32.ChecksumIEEE([]byte(secret))
|
||||||
actualChecksum, err := base62.Decode(tokenCheckSum)
|
actualChecksum, err := base62.Decode(tokenCheckSum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user