auth_handler_test.go 721 B

12345678910111213141516171819202122232425
  1. package handlers
  2. import "testing"
  3. func TestRefreshTokenHashRoundTrip(t *testing.T) {
  4. token, hash, err := newRefreshToken()
  5. if err != nil {
  6. t.Fatalf("newRefreshToken returned error: %v", err)
  7. }
  8. if token == "" || len(hash) != 64 {
  9. t.Fatalf("unexpected token/hash lengths: %d/%d", len(token), len(hash))
  10. }
  11. if got := hashRefreshToken(token); got != hash {
  12. t.Fatalf("hash mismatch: got %q want %q", got, hash)
  13. }
  14. }
  15. func TestNormalizeIdentifier(t *testing.T) {
  16. if got := normalizeIdentifier(" User@Example.COM "); got != "user@example.com" {
  17. t.Fatalf("email normalization = %q", got)
  18. }
  19. if got := normalizeIdentifier("138 0000 0000"); got != "13800000000" {
  20. t.Fatalf("phone normalization = %q", got)
  21. }
  22. }