@@ -32,6 +32,7 @@ import (
32
32
33
33
"github.com/coder/coder/cli/clitest"
34
34
"github.com/coder/coder/cli/config"
35
+ "github.com/coder/coder/coderd/coderdtest"
35
36
"github.com/coder/coder/coderd/database/postgres"
36
37
"github.com/coder/coder/coderd/telemetry"
37
38
"github.com/coder/coder/codersdk"
@@ -70,11 +71,7 @@ func TestServer(t *testing.T) {
70
71
accessURL := waitAccessURL (t , cfg )
71
72
client := codersdk .New (accessURL )
72
73
73
- _ , err = client .CreateFirstUser (ctx , codersdk.CreateFirstUserRequest {
74
-
75
- Username : "example" ,
76
- Password : "password" ,
77
- })
74
+ _ , err = client .CreateFirstUser (ctx , coderdtest .FirstUserParams )
78
75
require .NoError (t , err )
79
76
cancelFunc ()
80
77
require .NoError (t , <- errC )
@@ -540,6 +537,7 @@ func TestServer(t *testing.T) {
540
537
tlsListener bool
541
538
redirect bool
542
539
accessURL string
540
+ requestURL string
543
541
// Empty string means no redirect.
544
542
expectRedirect string
545
543
}{
@@ -558,6 +556,14 @@ func TestServer(t *testing.T) {
558
556
accessURL : "https://example.com" ,
559
557
expectRedirect : "" ,
560
558
},
559
+ {
560
+ name : "NoRedirectWithWildcard" ,
561
+ tlsListener : true ,
562
+ accessURL : "https://example.com" ,
563
+ requestURL : "https://dev.example.com" ,
564
+ expectRedirect : "" ,
565
+ redirect : true ,
566
+ },
561
567
{
562
568
name : "NoTLSListener" ,
563
569
httpListener : true ,
@@ -583,6 +589,10 @@ func TestServer(t *testing.T) {
583
589
ctx , cancelFunc := context .WithCancel (context .Background ())
584
590
defer cancelFunc ()
585
591
592
+ if c .requestURL == "" {
593
+ c .requestURL = c .accessURL
594
+ }
595
+
586
596
httpListenAddr := ""
587
597
if c .httpListener {
588
598
httpListenAddr = ":0"
@@ -601,6 +611,7 @@ func TestServer(t *testing.T) {
601
611
"--tls-address" , ":0" ,
602
612
"--tls-cert-file" , certPath ,
603
613
"--tls-key-file" , keyPath ,
614
+ "--wildcard-access-url" , "*.example.com" ,
604
615
)
605
616
}
606
617
if c .accessURL != "" {
@@ -661,7 +672,7 @@ func TestServer(t *testing.T) {
661
672
662
673
// Verify TLS
663
674
if c .tlsListener {
664
- accessURLParsed , err := url .Parse (c .accessURL )
675
+ accessURLParsed , err := url .Parse (c .requestURL )
665
676
require .NoError (t , err )
666
677
client := codersdk .New (accessURLParsed )
667
678
client .HTTPClient = & http.Client {
@@ -679,8 +690,9 @@ func TestServer(t *testing.T) {
679
690
}
680
691
defer client .HTTPClient .CloseIdleConnections ()
681
692
_ , err = client .HasFirstUser (ctx )
682
- require .NoError (t , err )
683
-
693
+ if err != nil {
694
+ require .ErrorContains (t , err , "Invalid application URL" )
695
+ }
684
696
cancelFunc ()
685
697
require .NoError (t , <- errC )
686
698
}
0 commit comments