mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-04-03 23:38:46 +02:00
* fixed doc comments and added unit tests Signed-off-by: anandf <anjoseph@redhat.com> * Added comments for the newly added unit tests Signed-off-by: anandf <anjoseph@redhat.com> * Refactored method name to deriveServiceAccountToImpersonate Signed-off-by: anandf <anjoseph@redhat.com> * Using const name in return value Signed-off-by: anandf <anjoseph@redhat.com> * Added unit tests for argocd proj add-destination-service-accounts Signed-off-by: anandf <anjoseph@redhat.com> * Fixed failing e2e tests Signed-off-by: anandf <anjoseph@redhat.com> * Fix linting errors Signed-off-by: anandf <anjoseph@redhat.com> * Using require package instead of assert and fixed code generation Signed-off-by: anandf <anjoseph@redhat.com> * Removed parallel execution of tests for sync with impersonate Signed-off-by: anandf <anjoseph@redhat.com> * Added err checks for glob validations Signed-off-by: anandf <anjoseph@redhat.com> * Fixed e2e tests for sync impersonation Signed-off-by: anandf <anjoseph@redhat.com> * Using consistently based expects in E2E tests Signed-off-by: anandf <anjoseph@redhat.com> * Added more unit tests and fixed go generate Signed-off-by: anandf <anjoseph@redhat.com> * Fixed failed lint errors, unit and e2e test failures Signed-off-by: anandf <anjoseph@redhat.com> * Fixed goimports linter issue Signed-off-by: anandf <anjoseph@redhat.com> * Added code comments and added few missing unit tests Signed-off-by: anandf <anjoseph@redhat.com> * Added missing unit test for GetDestinationServiceAccounts method Signed-off-by: anandf <anjoseph@redhat.com> * Fixed goimports formatting with local for project_test.go Signed-off-by: anandf <anjoseph@redhat.com> * Corrected typo in a field name additionalObjs Signed-off-by: anandf <anjoseph@redhat.com> * Fixed failing unit tests Signed-off-by: anandf <anjoseph@redhat.com> --------- Signed-off-by: anandf <anjoseph@redhat.com>
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package util
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
|
|
)
|
|
|
|
func TestProjectOpts_ResourceLists(t *testing.T) {
|
|
opts := ProjectOpts{
|
|
allowedNamespacedResources: []string{"ConfigMap"},
|
|
deniedNamespacedResources: []string{"apps/DaemonSet"},
|
|
allowedClusterResources: []string{"apiextensions.k8s.io/CustomResourceDefinition"},
|
|
deniedClusterResources: []string{"rbac.authorization.k8s.io/ClusterRole"},
|
|
}
|
|
|
|
assert.ElementsMatch(t,
|
|
[]v1.GroupKind{{Kind: "ConfigMap"}}, opts.GetAllowedNamespacedResources(),
|
|
[]v1.GroupKind{{Group: "apps", Kind: "DaemonSet"}}, opts.GetDeniedNamespacedResources(),
|
|
[]v1.GroupKind{{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}}, opts.GetAllowedClusterResources(),
|
|
[]v1.GroupKind{{Group: "rbac.authorization.k8s.io", Kind: "ClusterRole"}}, opts.GetDeniedClusterResources(),
|
|
)
|
|
}
|
|
|
|
func TestProjectOpts_GetDestinationServiceAccounts(t *testing.T) {
|
|
opts := ProjectOpts{
|
|
destinationServiceAccounts: []string{
|
|
"https://192.168.99.100:8443,test-ns,test-sa",
|
|
"https://kubernetes.default.svc.local:6443,guestbook,guestbook-sa",
|
|
},
|
|
}
|
|
|
|
assert.ElementsMatch(t,
|
|
[]v1alpha1.ApplicationDestinationServiceAccount{
|
|
{
|
|
Server: "https://192.168.99.100:8443",
|
|
Namespace: "test-ns",
|
|
DefaultServiceAccount: "test-sa",
|
|
},
|
|
{
|
|
Server: "https://kubernetes.default.svc.local:6443",
|
|
Namespace: "guestbook",
|
|
DefaultServiceAccount: "guestbook-sa",
|
|
},
|
|
}, opts.GetDestinationServiceAccounts(),
|
|
)
|
|
}
|