|
|
|
|
@@ -808,35 +808,35 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
// nolint:staticcheck
|
|
|
|
|
_, err = appServer.Get(noRoleCtx, &application.ApplicationQuery{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
// nolint:staticcheck
|
|
|
|
|
_, err = appServer.Get(adminCtx, &application.ApplicationQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
// nolint:staticcheck
|
|
|
|
|
_, err = appServer.Get(adminCtx, &application.ApplicationQuery{Name: ptr.To("doest-not-exist"), Project: []string{"test"}})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("GetManifests", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.GetManifests(noRoleCtx, &application.ApplicationManifestQuery{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ListResourceEvents", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ListResourceEvents(noRoleCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("UpdateSpec", func(t *testing.T) {
|
|
|
|
|
@@ -849,39 +849,39 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
Destination: appsv1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
|
|
|
|
Source: &appsv1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
|
|
|
|
}})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("doest-not-exist"), Spec: &appsv1.ApplicationSpec{
|
|
|
|
|
Destination: appsv1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
|
|
|
|
Source: &appsv1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
|
|
|
|
}})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), Spec: &appsv1.ApplicationSpec{
|
|
|
|
|
Destination: appsv1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
|
|
|
|
Source: &appsv1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
|
|
|
|
}})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("Patch", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.Patch(noRoleCtx, &application.ApplicationPatchRequest{Name: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("GetResource", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.GetResource(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("PatchResource", func(t *testing.T) {
|
|
|
|
|
@@ -890,33 +890,33 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
// The best we can do is to confirm we get past the permission check.
|
|
|
|
|
assert.NotEqual(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.PatchResource(noRoleCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("DeleteResource", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.DeleteResource(noRoleCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ResourceTree", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ResourceTree(noRoleCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("RevisionMetadata", func(t *testing.T) {
|
|
|
|
|
@@ -925,44 +925,44 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-multi"), SourceIndex: ptr.To(int32(0)), VersionId: ptr.To(int32(1))})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.RevisionMetadata(noRoleCtx, &application.RevisionMetadataQuery{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("RevisionChartDetails", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-helm")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.RevisionChartDetails(noRoleCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-helm")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ManagedResources", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ManagedResources(noRoleCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("Sync", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.Sync(noRoleCtx, &application.ApplicationSyncRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("TerminateOperation", func(t *testing.T) {
|
|
|
|
|
@@ -972,11 +972,11 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
_, err := appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.TerminateOperation(noRoleCtx, &application.OperationTerminateRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("Rollback", func(t *testing.T) {
|
|
|
|
|
@@ -986,103 +986,103 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("test-multi"), Id: ptr.To(int64(1))})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.Rollback(noRoleCtx, &application.ApplicationRollbackRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ListResourceActions", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("RunResourceAction", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Action: ptr.To("restart")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("GetApplicationSyncWindows", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.GetApplicationSyncWindows(noRoleCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("GetManifestsWithFiles", func(t *testing.T) {
|
|
|
|
|
err := appServer.GetManifestsWithFiles(&TestServerStream{ctx: adminCtx, appName: "test"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = appServer.GetManifestsWithFiles(&TestServerStream{ctx: noRoleCtx, appName: "test"})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.GetManifestsWithFiles(&TestServerStream{ctx: adminCtx, appName: "does-not-exist"})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.GetManifestsWithFiles(&TestServerStream{ctx: adminCtx, appName: "does-not-exist", project: "test"})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("WatchResourceTree", func(t *testing.T) {
|
|
|
|
|
err := appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("test")}, &TestResourceTreeServer{ctx: noRoleCtx})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("does-not-exist")}, &TestResourceTreeServer{ctx: adminCtx})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("does-not-exist"), Project: ptr.To("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("PodLogs", func(t *testing.T) {
|
|
|
|
|
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: noRoleCtx})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("does-not-exist")}, &TestPodLogsServer{ctx: adminCtx})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("does-not-exist"), Project: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ListLinks", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ListLinks(noRoleCtx, &application.ListAppLinksRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("does-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("does-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ListResourceLinks", func(t *testing.T) {
|
|
|
|
|
_, err := appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.ListResourceLinks(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("does-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("does-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Do this last so other stuff doesn't fail.
|
|
|
|
|
@@ -1090,11 +1090,11 @@ func TestNoAppEnumeration(t *testing.T) {
|
|
|
|
|
_, err := appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("test")})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = appServer.Delete(noRoleCtx, &application.ApplicationDeleteRequest{Name: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("doest-not-exist")})
|
|
|
|
|
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
require.EqualError(t, err, permissionDeniedErr.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
|
|
|
|
_, err = appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
|
|
|
|
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1669,7 +1669,7 @@ func TestDeleteResourcesRBAC(t *testing.T) {
|
|
|
|
|
p, test-user, applications, delete, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.DeleteResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenDeleteAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenDeleteAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("delete with application permission but deny subresource", func(t *testing.T) {
|
|
|
|
|
@@ -1678,7 +1678,7 @@ p, test-user, applications, delete, default/test-app, allow
|
|
|
|
|
p, test-user, applications, delete/*, default/test-app, deny
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.DeleteResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenDeleteAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenDeleteAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("delete with subresource", func(t *testing.T) {
|
|
|
|
|
@@ -1686,7 +1686,7 @@ p, test-user, applications, delete/*, default/test-app, deny
|
|
|
|
|
p, test-user, applications, delete/*, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.DeleteResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenDeleteAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenDeleteAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("delete with subresource but deny applications", func(t *testing.T) {
|
|
|
|
|
@@ -1695,7 +1695,7 @@ p, test-user, applications, delete, default/test-app, deny
|
|
|
|
|
p, test-user, applications, delete/*, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.DeleteResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenDeleteAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenDeleteAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("delete with specific subresource denied", func(t *testing.T) {
|
|
|
|
|
@@ -1732,7 +1732,7 @@ func TestPatchResourcesRBAC(t *testing.T) {
|
|
|
|
|
p, test-user, applications, update, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.PatchResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenUpdateAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenUpdateAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("patch with application permission but deny subresource", func(t *testing.T) {
|
|
|
|
|
@@ -1741,7 +1741,7 @@ p, test-user, applications, update, default/test-app, allow
|
|
|
|
|
p, test-user, applications, update/*, default/test-app, deny
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.PatchResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenUpdateAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenUpdateAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("patch with subresource", func(t *testing.T) {
|
|
|
|
|
@@ -1749,7 +1749,7 @@ p, test-user, applications, update/*, default/test-app, deny
|
|
|
|
|
p, test-user, applications, update/*, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.PatchResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenUpdateAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenUpdateAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("patch with subresource but deny applications", func(t *testing.T) {
|
|
|
|
|
@@ -1758,7 +1758,7 @@ p, test-user, applications, update, default/test-app, deny
|
|
|
|
|
p, test-user, applications, update/*, default/test-app, allow
|
|
|
|
|
`)
|
|
|
|
|
_, err := appServer.PatchResource(ctx, &req)
|
|
|
|
|
assert.Equal(t, expectedErrorWhenUpdateAllowed, err.Error())
|
|
|
|
|
assert.EqualError(t, err, expectedErrorWhenUpdateAllowed)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("patch with specific subresource denied", func(t *testing.T) {
|
|
|
|
|
@@ -2205,7 +2205,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
statusCode, _ := status.FromError(err)
|
|
|
|
|
assert.Equal(t, codes.InvalidArgument, statusCode.Code())
|
|
|
|
|
assert.Equal(t, "rpc error: code = InvalidArgument desc = max pods to view logs are reached. Please provide more granular query", err.Error())
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = InvalidArgument desc = max pods to view logs are reached. Please provide more granular query")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Case: number of pods to view logs is less than customMaxPodLogsToRender
|
|
|
|
|
@@ -2229,7 +2229,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
statusCode, _ := status.FromError(err)
|
|
|
|
|
assert.Equal(t, codes.InvalidArgument, statusCode.Code())
|
|
|
|
|
assert.Equal(t, "rpc error: code = InvalidArgument desc = max pods to view logs are reached. Please provide more granular query", err.Error())
|
|
|
|
|
assert.EqualError(t, err, "rpc error: code = InvalidArgument desc = max pods to view logs are reached. Please provide more granular query")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2510,7 +2510,7 @@ func TestRunNewStyleResourceAction(t *testing.T) {
|
|
|
|
|
Kind: &kind,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, runErr.Error(), "is not permitted to manage")
|
|
|
|
|
require.ErrorContains(t, runErr, "is not permitted to manage")
|
|
|
|
|
assert.Nil(t, appResponse)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -2953,16 +2953,12 @@ func TestGetAmbiguousRevision_MultiSource(t *testing.T) {
|
|
|
|
|
sourceIndex := 0
|
|
|
|
|
expected := "rev1"
|
|
|
|
|
result := getAmbiguousRevision(app, syncReq, sourceIndex)
|
|
|
|
|
if result != expected {
|
|
|
|
|
t.Errorf("Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
assert.Equalf(t, expected, result, "Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
|
|
|
|
|
sourceIndex = 1
|
|
|
|
|
expected = "rev2"
|
|
|
|
|
result = getAmbiguousRevision(app, syncReq, sourceIndex)
|
|
|
|
|
if result != expected {
|
|
|
|
|
t.Errorf("Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
assert.Equal(t, expected, result, "Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
|
|
|
|
|
// Test when app.Spec.HasMultipleSources() is false
|
|
|
|
|
app.Spec = appv1.ApplicationSpec{
|
|
|
|
|
@@ -2976,9 +2972,7 @@ func TestGetAmbiguousRevision_MultiSource(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
expected = "revision3"
|
|
|
|
|
result = getAmbiguousRevision(app, syncReq, sourceIndex)
|
|
|
|
|
if result != expected {
|
|
|
|
|
t.Errorf("Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
assert.Equal(t, expected, result, "Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGetAmbiguousRevision_SingleSource(t *testing.T) {
|
|
|
|
|
@@ -2997,9 +2991,7 @@ func TestGetAmbiguousRevision_SingleSource(t *testing.T) {
|
|
|
|
|
sourceIndex := 1
|
|
|
|
|
expected := "rev1"
|
|
|
|
|
result := getAmbiguousRevision(app, syncReq, sourceIndex)
|
|
|
|
|
if result != expected {
|
|
|
|
|
t.Errorf("Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
assert.Equalf(t, expected, result, "Expected ambiguous revision to be %s, but got %s", expected, result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestServer_ResolveSourceRevisions_MultiSource(t *testing.T) {
|
|
|
|
|
|