@@ -1750,16 +1750,16 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
1750
1750
return c
1751
1751
}
1752
1752
1753
- // authenticatedClient := func(t *testing.T, appDetails *Details) *codersdk.Client {
1754
- // uc, _ := coderdtest.CreateAnotherUser(t, appDetails.SDKClient, appDetails.FirstUser.OrganizationID, rbac.RoleMember())
1755
- // c := appDetails.AppClient(t)
1756
- // c.SetSessionToken(uc.SessionToken())
1757
- // return c
1758
- // }
1753
+ authenticatedClient := func (t * testing.T , appDetails * Details ) * codersdk.Client {
1754
+ uc , _ := coderdtest .CreateAnotherUser (t , appDetails .SDKClient , appDetails .FirstUser .OrganizationID , rbac .RoleMember ())
1755
+ c := appDetails .AppClient (t )
1756
+ c .SetSessionToken (uc .SessionToken ())
1757
+ return c
1758
+ }
1759
1759
1760
- // ownerClient := func(t *testing.T, appDetails *Details) *codersdk.Client {
1761
- // return appDetails.SDKClient
1762
- // }
1760
+ ownerClient := func (t * testing.T , appDetails * Details ) * codersdk.Client {
1761
+ return appDetails .SDKClient
1762
+ }
1763
1763
1764
1764
tests := []struct {
1765
1765
name string
@@ -1778,58 +1778,58 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
1778
1778
client : unauthenticatedClient ,
1779
1779
expectedStatusCode : http .StatusOK ,
1780
1780
},
1781
- // {
1782
- // name: "Passthru/Public",
1783
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelPublic,
1784
- // behavior: codersdk.CORSBehaviorPassthru,
1785
- // expectedCORSHeaders: true,
1786
- // client: unauthenticatedClient,
1787
- // expectedStatusCode: http.StatusOK,
1788
- // },
1789
- // // Authenticated
1790
- // {
1791
- // name: "Default/Authenticated",
1792
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelAuthenticated,
1793
- // behavior: codersdk.CORSBehaviorSimple,
1794
- // expectedCORSHeaders: false,
1795
- // client: authenticatedClient,
1796
- // expectedStatusCode: http.StatusOK,
1797
- // },
1798
- // {
1799
- // name: "Passthru/Authenticated",
1800
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelAuthenticated,
1801
- // behavior: codersdk.CORSBehaviorPassthru,
1802
- // expectedCORSHeaders: true,
1803
- // client: authenticatedClient,
1804
- // expectedStatusCode: http.StatusOK,
1805
- // },
1806
- // {
1807
- // // The CORS behavior will not affect unauthenticated requests.
1808
- // // The request will be redirected to the login page.
1809
- // name: "Passthru/Unauthenticated",
1810
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelAuthenticated,
1811
- // behavior: codersdk.CORSBehaviorPassthru,
1812
- // expectedCORSHeaders: false,
1813
- // client: unauthenticatedClient,
1814
- // expectedStatusCode: http.StatusSeeOther,
1815
- // },
1816
- // // Owner
1817
- // {
1818
- // name: "Default/Owner",
1819
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelAuthenticated, // Owner is not a valid share level for ports.
1820
- // behavior: codersdk.CORSBehaviorSimple,
1821
- // expectedCORSHeaders: false,
1822
- // client: ownerClient,
1823
- // expectedStatusCode: http.StatusOK,
1824
- // },
1825
- // {
1826
- // name: "Passthru/Owner",
1827
- // shareLevel: codersdk.WorkspaceAgentPortShareLevelAuthenticated, // Owner is not a valid share level for ports.
1828
- // behavior: codersdk.CORSBehaviorPassthru,
1829
- // expectedCORSHeaders: true,
1830
- // client: ownerClient,
1831
- // expectedStatusCode: http.StatusOK,
1832
- // },
1781
+ { // fails
1782
+ name : "Passthru/Public" ,
1783
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelPublic ,
1784
+ behavior : codersdk .CORSBehaviorPassthru ,
1785
+ expectedCORSHeaders : true ,
1786
+ client : unauthenticatedClient ,
1787
+ expectedStatusCode : http .StatusOK ,
1788
+ },
1789
+ // Authenticated
1790
+ {
1791
+ name : "Default/Authenticated" ,
1792
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelAuthenticated ,
1793
+ behavior : codersdk .CORSBehaviorSimple ,
1794
+ expectedCORSHeaders : false ,
1795
+ client : authenticatedClient ,
1796
+ expectedStatusCode : http .StatusOK ,
1797
+ },
1798
+ { // fails
1799
+ name : "Passthru/Authenticated" ,
1800
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelAuthenticated ,
1801
+ behavior : codersdk .CORSBehaviorPassthru ,
1802
+ expectedCORSHeaders : true ,
1803
+ client : authenticatedClient ,
1804
+ expectedStatusCode : http .StatusOK ,
1805
+ },
1806
+ {
1807
+ // The CORS behavior will not affect unauthenticated requests.
1808
+ // The request will be redirected to the login page.
1809
+ name : "Passthru/Unauthenticated" ,
1810
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelAuthenticated ,
1811
+ behavior : codersdk .CORSBehaviorPassthru ,
1812
+ expectedCORSHeaders : false ,
1813
+ client : unauthenticatedClient ,
1814
+ expectedStatusCode : http .StatusSeeOther ,
1815
+ },
1816
+ // Owner
1817
+ {
1818
+ name : "Default/Owner" ,
1819
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelAuthenticated , // Owner is not a valid share level for ports.
1820
+ behavior : codersdk .CORSBehaviorSimple ,
1821
+ expectedCORSHeaders : false ,
1822
+ client : ownerClient ,
1823
+ expectedStatusCode : http .StatusOK ,
1824
+ },
1825
+ { // fails
1826
+ name : "Passthru/Owner" ,
1827
+ shareLevel : codersdk .WorkspaceAgentPortShareLevelAuthenticated , // Owner is not a valid share level for ports.
1828
+ behavior : codersdk .CORSBehaviorPassthru ,
1829
+ expectedCORSHeaders : true ,
1830
+ client : ownerClient ,
1831
+ expectedStatusCode : http .StatusOK ,
1832
+ },
1833
1833
}
1834
1834
1835
1835
for _ , tc := range tests {
@@ -1870,8 +1870,8 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
1870
1870
require .Equal (t , tc .expectedStatusCode , resp .StatusCode )
1871
1871
1872
1872
if tc .expectedCORSHeaders {
1873
- require .Equal (t , testHeaders .Get ("Access-Control-Allow-Origin" ), resp .Header .Get ("Access-Control-Allow-Origin" ))
1874
- require .Equal (t , testHeaders .Get ("Access-Control-Allow-Methods" ), resp .Header .Get ("Access-Control-Allow-Methods" ))
1873
+ require .Equal (t , testHeaders .Get ("Access-Control-Allow-Origin" ), resp .Header .Get ("Access-Control-Allow-Origin" ), "allow origin did not match" )
1874
+ require .Equal (t , testHeaders .Get ("Access-Control-Allow-Methods" ), resp .Header .Get ("Access-Control-Allow-Methods" ), "allow methods did not match" )
1875
1875
} else {
1876
1876
require .Empty (t , resp .Header .Get ("Access-Control-Allow-Origin" ))
1877
1877
require .Empty (t , resp .Header .Get ("Access-Control-Allow-Methods" ))
0 commit comments