@@ -615,6 +615,76 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
615
615
})
616
616
}
617
617
618
+ func TestWorkspaceProxyWorkspaceApps_BlockDirect (t * testing.T ) {
619
+ t .Parallel ()
620
+
621
+ apptest .Run (t , false , func (t * testing.T , opts * apptest.DeploymentOptions ) * apptest.Deployment {
622
+ deploymentValues := coderdtest .DeploymentValues (t )
623
+ deploymentValues .DisablePathApps = clibase .Bool (opts .DisablePathApps )
624
+ deploymentValues .Dangerous .AllowPathAppSharing = clibase .Bool (opts .DangerousAllowPathAppSharing )
625
+ deploymentValues .Dangerous .AllowPathAppSiteOwnerAccess = clibase .Bool (opts .DangerousAllowPathAppSiteOwnerAccess )
626
+ deploymentValues .Experiments = []string {
627
+ "*" ,
628
+ }
629
+
630
+ proxyStatsCollectorFlushCh := make (chan chan <- struct {}, 1 )
631
+ flushStats := func () {
632
+ proxyStatsCollectorFlushDone := make (chan struct {}, 1 )
633
+ proxyStatsCollectorFlushCh <- proxyStatsCollectorFlushDone
634
+ <- proxyStatsCollectorFlushDone
635
+ }
636
+
637
+ if opts .PrimaryAppHost == "" {
638
+ opts .PrimaryAppHost = "*.primary.test.coder.com"
639
+ }
640
+ client , closer , api , user := coderdenttest .NewWithAPI (t , & coderdenttest.Options {
641
+ Options : & coderdtest.Options {
642
+ DeploymentValues : deploymentValues ,
643
+ AppHostname : opts .PrimaryAppHost ,
644
+ IncludeProvisionerDaemon : true ,
645
+ RealIPConfig : & httpmw.RealIPConfig {
646
+ TrustedOrigins : []* net.IPNet {{
647
+ IP : net .ParseIP ("127.0.0.1" ),
648
+ Mask : net .CIDRMask (8 , 32 ),
649
+ }},
650
+ TrustedHeaders : []string {
651
+ "CF-Connecting-IP" ,
652
+ },
653
+ },
654
+ WorkspaceAppsStatsCollectorOptions : opts .StatsCollectorOptions ,
655
+ },
656
+ LicenseOptions : & coderdenttest.LicenseOptions {
657
+ Features : license.Features {
658
+ codersdk .FeatureWorkspaceProxy : 1 ,
659
+ },
660
+ },
661
+ })
662
+ t .Cleanup (func () {
663
+ _ = closer .Close ()
664
+ })
665
+
666
+ // Create the external proxy
667
+ if opts .DisableSubdomainApps {
668
+ opts .AppHost = ""
669
+ }
670
+ proxyAPI := coderdenttest .NewWorkspaceProxyReplica (t , api , client , & coderdenttest.ProxyOptions {
671
+ Name : "best-proxy" ,
672
+ AppHostname : opts .AppHost ,
673
+ DisablePathApps : opts .DisablePathApps ,
674
+ FlushStats : proxyStatsCollectorFlushCh ,
675
+ BlockDirect : true ,
676
+ })
677
+
678
+ return & apptest.Deployment {
679
+ Options : opts ,
680
+ SDKClient : client ,
681
+ FirstUser : user ,
682
+ PathAppBaseURL : proxyAPI .Options .AccessURL ,
683
+ FlushStats : flushStats ,
684
+ }
685
+ })
686
+ }
687
+
618
688
// createDERPClient creates a DERP client and spawns a goroutine that reads from
619
689
// the client and sends the received packets to a channel.
620
690
//
0 commit comments