test: add device token validation and text utility tests

This commit is contained in:
2026-02-14 21:38:00 -05:00
parent 4d15dba555
commit acd194c217
2 changed files with 39 additions and 0 deletions
+21
View File
@@ -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")
}