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), 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
} }

View File

@ -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)