snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
70
cmd/migrate/normalize_phone_handler_test.go
Normal file
70
cmd/migrate/normalize_phone_handler_test.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright © 2026 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/ory/kratos/x"
|
||||
)
|
||||
|
||||
func TestNormalizePhoneIdentifier(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
input string
|
||||
expected string
|
||||
shouldSkip bool
|
||||
}{
|
||||
{
|
||||
name: "German phone with spaces",
|
||||
input: "+49 176 671 11 638",
|
||||
expected: "+4917667111638",
|
||||
},
|
||||
{
|
||||
name: "German phone with dashes",
|
||||
input: "+49-176-671-11-638",
|
||||
expected: "+4917667111638",
|
||||
},
|
||||
{
|
||||
name: "Already normalized E.164",
|
||||
input: "+4917667111638",
|
||||
expected: "+4917667111638",
|
||||
shouldSkip: true,
|
||||
},
|
||||
{
|
||||
name: "US phone with parens",
|
||||
input: "+1 (415) 555-2671",
|
||||
expected: "+14155552671",
|
||||
},
|
||||
{
|
||||
name: "Malaysian phone with extra zero",
|
||||
input: "+600136866982",
|
||||
expected: "+60136866982",
|
||||
},
|
||||
{
|
||||
name: "Not a valid phone number",
|
||||
input: "+invalid",
|
||||
expected: "+invalid",
|
||||
shouldSkip: true,
|
||||
},
|
||||
{
|
||||
name: "Email address (not a phone)",
|
||||
input: "+foo@bar.com",
|
||||
expected: "+foo@bar.com",
|
||||
shouldSkip: true,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
normalized := x.NormalizePhoneIdentifier(tc.input)
|
||||
assert.Equal(t, tc.expected, normalized)
|
||||
if tc.shouldSkip {
|
||||
assert.Equal(t, tc.input, normalized, "should be unchanged (skip)")
|
||||
} else {
|
||||
assert.NotEqual(t, tc.input, normalized, "should be changed (update)")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user