mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-20 09:16:40 +00:00
merge main
This commit is contained in:
@@ -96,51 +96,3 @@ func TestGetClusterAllowList_BYOPEmptySlice_FallbackToShared(t *testing.T) {
|
||||
assert.Equal(t, []string{"eu.proxy.netbird.io"}, result)
|
||||
}
|
||||
|
||||
func TestExtractClusterFromFreeDomain(t *testing.T) {
|
||||
clusters := []string{"eu.proxy.netbird.io", "us.proxy.netbird.io"}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
domain string
|
||||
wantCluster string
|
||||
wantOK bool
|
||||
}{
|
||||
{
|
||||
name: "matches EU cluster",
|
||||
domain: "myapp.abc123.eu.proxy.netbird.io",
|
||||
wantCluster: "eu.proxy.netbird.io",
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "matches US cluster",
|
||||
domain: "myapp.xyz789.us.proxy.netbird.io",
|
||||
wantCluster: "us.proxy.netbird.io",
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "no match - custom domain",
|
||||
domain: "app.example.com",
|
||||
wantOK: false,
|
||||
},
|
||||
{
|
||||
name: "no match - partial cluster name",
|
||||
domain: "proxy.netbird.io",
|
||||
wantOK: false,
|
||||
},
|
||||
{
|
||||
name: "exact cluster name - no prefix",
|
||||
domain: "eu.proxy.netbird.io",
|
||||
wantOK: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cluster, ok := ExtractClusterFromFreeDomain(tt.domain, clusters)
|
||||
assert.Equal(t, tt.wantOK, ok)
|
||||
if tt.wantOK {
|
||||
assert.Equal(t, tt.wantCluster, cluster)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user