mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
55 lines
875 B
Go
55 lines
875 B
Go
package security
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_AppRBACName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testCases := []struct {
|
|
name string
|
|
defaultNS string
|
|
project string
|
|
namespace string
|
|
appName string
|
|
expectedResult string
|
|
}{
|
|
{
|
|
"namespace is empty",
|
|
"argocd",
|
|
"default",
|
|
"",
|
|
"app",
|
|
"default/app",
|
|
},
|
|
{
|
|
"namespace is default namespace",
|
|
"argocd",
|
|
"default",
|
|
"argocd",
|
|
"app",
|
|
"default/app",
|
|
},
|
|
{
|
|
"namespace is not default namespace",
|
|
"argocd",
|
|
"default",
|
|
"test",
|
|
"app",
|
|
"default/test/app",
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tcc := tc
|
|
t.Run(tcc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
result := RBACName(tcc.defaultNS, tcc.project, tcc.namespace, tcc.appName)
|
|
assert.Equal(t, tcc.expectedResult, result)
|
|
})
|
|
}
|
|
}
|