fixed some namings

This commit is contained in:
Pascal Fischer 2023-03-06 13:49:07 +01:00
parent 2f2d45de9e
commit 95d87384ab
2 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ func CreateNewPAT(description string, expirationInDays int, createdBy string) (*
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
CreatedBy: createdBy,
CreatedAt: currentTime,
LastUsed: currentTime, // using creation time as nil not possible
LastUsed: currentTime,
}, plainToken
}

View File

@ -18,8 +18,8 @@ func TestPAT_GenerateToken_Hashing(t *testing.T) {
func TestPAT_GenerateToken_Prefix(t *testing.T) {
_, plainToken := generateNewToken()
fourLetterPrefix := plainToken[:4]
assert.Equal(t, "nbp_", fourLetterPrefix)
fourCharPrefix := plainToken[:4]
assert.Equal(t, "nbp_", fourCharPrefix)
}
func TestPAT_GenerateToken_Checksum(t *testing.T) {
@ -28,10 +28,10 @@ func TestPAT_GenerateToken_Checksum(t *testing.T) {
if len(tokenWithoutPrefix) != 36 {
t.Fatal("Token has wrong length")
}
token := tokenWithoutPrefix[:len(tokenWithoutPrefix)-6]
secret := tokenWithoutPrefix[:len(tokenWithoutPrefix)-6]
tokenCheckSum := tokenWithoutPrefix[len(tokenWithoutPrefix)-6:]
expectedChecksum := crc32.ChecksumIEEE([]byte(token))
expectedChecksum := crc32.ChecksumIEEE([]byte(secret))
actualChecksum, err := base62.Decode(tokenCheckSum)
if err != nil {
t.Fatal(err)