github.com/argoproj/argo-cd/v3@v3.2.1/util/security/rbac_test.go (about) 1 package security 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_AppRBACName(t *testing.T) { 10 t.Parallel() 11 12 testCases := []struct { 13 name string 14 defaultNS string 15 project string 16 namespace string 17 appName string 18 expectedResult string 19 }{ 20 { 21 "namespace is empty", 22 "argocd", 23 "default", 24 "", 25 "app", 26 "default/app", 27 }, 28 { 29 "namespace is default namespace", 30 "argocd", 31 "default", 32 "argocd", 33 "app", 34 "default/app", 35 }, 36 { 37 "namespace is not default namespace", 38 "argocd", 39 "default", 40 "test", 41 "app", 42 "default/test/app", 43 }, 44 } 45 46 for _, tc := range testCases { 47 tcc := tc 48 t.Run(tcc.name, func(t *testing.T) { 49 t.Parallel() 50 result := RBACName(tcc.defaultNS, tcc.project, tcc.namespace, tcc.appName) 51 assert.Equal(t, tcc.expectedResult, result) 52 }) 53 } 54 }