From 26b53c79df30bcc3d2c4bf5782fe65b2cf1b0899 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Mon, 20 Jan 2025 12:11:17 +0300 Subject: [PATCH 1/3] allow period for the alias --- identity/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identity/alias.go b/identity/alias.go index 195bcd5..f14774b 100644 --- a/identity/alias.go +++ b/identity/alias.go @@ -5,7 +5,7 @@ import ( ) const ( - aliasRegex = `^[a-zA-Z0-9]+$` + aliasRegex = `^[a-zA-Z0-9.]+$` ) // IsValidAlias checks if the alias is a valid alias format -- 2.45.2 From 3e859d3469ecb0250161abcba4276a4937777e50 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Tue, 21 Jan 2025 13:15:53 +0300 Subject: [PATCH 2/3] allow period for the alias regex --- identity/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identity/alias.go b/identity/alias.go index f14774b..0971c48 100644 --- a/identity/alias.go +++ b/identity/alias.go @@ -5,7 +5,7 @@ import ( ) const ( - aliasRegex = `^[a-zA-Z0-9.]+$` + aliasRegex = `^[a-zA-Z0-9]+(\.[a-zA-Z0.9]+)*$` ) // IsValidAlias checks if the alias is a valid alias format -- 2.45.2 From b4cd696f489b7191952dca745c713c263c9877ca Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Tue, 21 Jan 2025 13:16:14 +0300 Subject: [PATCH 3/3] test alias regex --- identity/alias_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 identity/alias_test.go diff --git a/identity/alias_test.go b/identity/alias_test.go new file mode 100644 index 0000000..cc712bd --- /dev/null +++ b/identity/alias_test.go @@ -0,0 +1,41 @@ +package identity + +import ( + "testing" +) + +func TestAliasesRegext(t *testing.T) { + tests := []struct { + alias string + isValid bool + }{ + { + alias: "foobar", + isValid: true, + }, + { + alias: "foo.sarafu.local", + isValid: true, + }, + { + alias: "foo.sarafu", + isValid: true, + }, + { + alias: "foo.", + isValid: false, + }, + { + alias: ".foo..bar", + isValid: false, + }, + } + for _, tt := range tests { + t.Run(tt.alias, func(t *testing.T) { + isValid := IsValidAlias(tt.alias) + if isValid != tt.isValid { + t.Fatalf("expected %v, got %v", tt.isValid, isValid) + } + }) + } +} -- 2.45.2