@@ -32,6 +32,9 @@ func (t *testRBAC) GetCustomPermissions(ctx context.Context) ([]string, error) {
3232 return t .perms , nil
3333}
3434
35+ func (t * testRBAC ) IsAppRBACEnabled (ctx context.Context ) bool {
36+ return true
37+ }
3538func TestProxyBasics (t * testing.T ) {
3639 testServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
3740 if r .URL .Path != "/abc" {
@@ -676,9 +679,11 @@ func TestProxyUserAndPermsHeaders(t *testing.T) {
676679 // Test that X-Openrun-User and X-Openrun-Perms headers are passed to proxied endpoint
677680 var receivedUser string
678681 var receivedPerms string
682+ var receivedRBACEnabled string
679683 testServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
680684 receivedUser = r .Header .Get ("X-Openrun-User" )
681685 receivedPerms = r .Header .Get ("X-Openrun-Perms" )
686+ receivedRBACEnabled = r .Header .Get ("X-Openrun-Rbac-Enabled" )
682687 io .WriteString (w , "test contents" ) //nolint:errcheck
683688 }))
684689
@@ -694,19 +699,6 @@ permissions=[
694699)` , testServer .URL ),
695700 }
696701
697- /*
698- // Create custom authorizer and perms func
699- _ := func(ctx context.Context, permissions []string) (bool, error) {
700- // Always allow
701- return true, nil
702- }
703-
704- _ := func(ctx context.Context) ([]string, error) {
705- // Return custom permissions
706- return []string{"read:data", "write:data", "admin"}, nil
707- }
708- */
709-
710702 a , _ , err := CreateTestAppAuthorizer (logger , fileData , []string {"proxy.in" },
711703 []types.Permission {
712704 {Plugin : "proxy.in" , Method : "config" },
@@ -728,6 +720,7 @@ permissions=[
728720 // Verify the headers were passed to the proxied endpoint
729721 testutil .AssertEqualsString (t , "X-Openrun-User" , types .ANONYMOUS_USER , receivedUser )
730722 testutil .AssertEqualsString (t , "X-Openrun-Perms" , "read:data,write:data,admin" , receivedPerms )
723+ testutil .AssertEqualsString (t , "X-Openrun-Rbac-Enabled" , "true" , receivedRBACEnabled )
731724}
732725
733726func TestProxyUserHeaderWithAuthentication (t * testing.T ) {
@@ -752,19 +745,6 @@ permissions=[
752745)` , testServer .URL ),
753746 }
754747
755- /*
756- // Create custom authorizer that sets a user in context
757- authorizer := func(ctx context.Context, permissions []string) (bool, error) {
758- // Always allow
759- return true, nil
760- }
761-
762- customPermsFunc := func(ctx context.Context) ([]string, error) {
763- // Return empty custom permissions
764- return []string{}, nil
765- }
766- */
767-
768748 a , _ , err := CreateTestAppAuthorizer (logger , fileData , []string {"proxy.in" },
769749 []types.Permission {
770750 {Plugin : "proxy.in" , Method : "config" },
0 commit comments