test: add device token validation and text utility tests
This commit is contained in:
@@ -200,3 +200,24 @@ func TestDeviceUpdateRequest_Validation(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateDeviceToken(t *testing.T) {
|
||||
hashedToken := []byte("$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi")
|
||||
plainToken := "password"
|
||||
|
||||
result := ValidateDeviceToken(string(hashedToken), plainToken)
|
||||
assert.True(t, result, "Valid token should return true")
|
||||
}
|
||||
|
||||
func TestValidateDeviceToken_Invalid(t *testing.T) {
|
||||
hashedToken := []byte("$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi")
|
||||
plainToken := "wrongpassword"
|
||||
|
||||
result := ValidateDeviceToken(string(hashedToken), plainToken)
|
||||
assert.False(t, result, "Invalid token should return false")
|
||||
}
|
||||
|
||||
func TestValidateDeviceToken_Empty(t *testing.T) {
|
||||
result := ValidateDeviceToken("", "anypassword")
|
||||
assert.False(t, result, "Empty hash should return false")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user