@@ -2,6 +2,7 @@ package aws
2
2
3
3
import (
4
4
"context"
5
+ "regexp"
5
6
"testing"
6
7
7
8
"github.com/DefangLabs/defang/src/pkg/cli/client"
@@ -23,17 +24,17 @@ func TestDomainMultipleProjectSupport(t *testing.T) {
23
24
PublicFqdn string
24
25
PrivateFqdn string
25
26
}{
26
- {"tenant1" , "tenant1" , "web" , port80 , " web--80.1fa1857b71717f6b .example.com" , " web.1fa1857b71717f6b .example.com" , "web.tenant1.internal" },
27
- {"tenant1" , "tenant1" , "web" , hostModePort , " web.tenant1.internal:80" , " web.1fa1857b71717f6b .example.com" , "web.tenant1.internal" },
28
- {"project1" , "tenant1" , "web" , port80 , " web--80.1ac7562668796635 .example.com" , " web.1ac7562668796635 .example.com" , "web.project1.internal" },
29
- {"Project1" , "tenant1" , "web" , port80 , " web--80.40b35d8b26ff71ae .example.com" , " web.40b35d8b26ff71ae .example.com" , "web.project1.internal" },
30
- {"project1" , "tenant1" , "web" , hostModePort , " web.project1.internal:80" , " web.1ac7562668796635 .example.com" , "web.project1.internal" },
31
- {"project1" , "tenant1" , "api" , port8080 , " api--8080.1ac7562668796635 .example.com" , " api.1ac7562668796635 .example.com" , "api.project1.internal" },
32
- {"tenant1" , "tenant1" , "web" , port80 , " web--80.1fa1857b71717f6b .example.com" , " web.1fa1857b71717f6b .example.com" , "web.tenant1.internal" },
33
- {"tenant1" , "tenant1" , "web" , hostModePort , " web.tenant1.internal:80" , " web.1fa1857b71717f6b .example.com" , "web.tenant1.internal" },
34
- {"Project1" , "tenant1" , "web" , port80 , " web--80.40b35d8b26ff71ae .example.com" , " web.40b35d8b26ff71ae .example.com" , "web.project1.internal" },
35
- {"Tenant2" , "tenant1" , "web" , port80 , " web--80.f5600a0d61784e9d .example.com" , " web.f5600a0d61784e9d .example.com" , "web.tenant2.internal" },
36
- {"tenant1" , "tenAnt1" , "web" , port80 , " web--80.7360f2237c979f46 .example.com" , " web.7360f2237c979f46 .example.com" , "web.tenant1.internal" },
27
+ {"tenant1" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.tenant1.internal" },
28
+ {"tenant1" , "tenant1" , "web" , hostModePort , ` web\ .tenant1.internal:80` , ` web.[0-9a-z]{12} .example\ .com` , "web.tenant1.internal" },
29
+ {"project1" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.project1.internal" },
30
+ {"Project1" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.project1.internal" },
31
+ {"project1" , "tenant1" , "web" , hostModePort , ` web\ .project1\ .internal:80` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.project1.internal" },
32
+ {"project1" , "tenant1" , "api" , port8080 , ` api--8080\.[0-9a-z]{12}\ .example\ .com` , ` api\.[0-9a-z]{12}\ .example\ .com` , "api.project1.internal" },
33
+ {"tenant1" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.tenant1.internal" },
34
+ {"tenant1" , "tenant1" , "web" , hostModePort , ` web\ .tenant1\ .internal:80` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.tenant1.internal" },
35
+ {"Project1" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.project1.internal" },
36
+ {"Tenant2" , "tenant1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.tenant2.internal" },
37
+ {"tenant1" , "tenAnt1" , "web" , port80 , ` web--80\.[0-9a-z]{12}\ .example\ .com` , ` web\.[0-9a-z]{12}\ .example\ .com` , "web.tenant1.internal" },
37
38
}
38
39
39
40
for _ , tt := range tests {
@@ -46,12 +47,12 @@ func TestDomainMultipleProjectSupport(t *testing.T) {
46
47
b .ProjectDomain = b .getProjectDomain ("123456789012" , "example.com" )
47
48
48
49
endpoint := b .getEndpoint (tt .Fqn , tt .Port )
49
- if endpoint != tt .EndPoint {
50
+ if ! regexp . MustCompile ( tt .EndPoint ). MatchString ( endpoint ) {
50
51
t .Errorf ("expected endpoint %q, got %q" , tt .EndPoint , endpoint )
51
52
}
52
53
53
54
publicFqdn := b .getPublicFqdn (tt .Fqn )
54
- if publicFqdn != tt .PublicFqdn {
55
+ if ! regexp . MustCompile ( tt .PublicFqdn ). MatchString ( publicFqdn ) {
55
56
t .Errorf ("expected public fqdn %q, got %q" , tt .PublicFqdn , publicFqdn )
56
57
}
57
58
0 commit comments