2024-07-31 12:42:12 +00:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
package action_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2024-08-12 20:32:01 +00:00
|
|
|
object "github.com/zitadel/zitadel/pkg/grpc/object/v3alpha"
|
2024-07-31 12:42:12 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/muhlemmer/gu"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"google.golang.org/protobuf/types/known/durationpb"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/integration"
|
|
|
|
action "github.com/zitadel/zitadel/pkg/grpc/resources/action/v3alpha"
|
|
|
|
resource_object "github.com/zitadel/zitadel/pkg/grpc/resources/object/v3alpha"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestServer_CreateTarget(t *testing.T) {
|
2024-08-12 20:32:01 +00:00
|
|
|
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
|
|
|
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
2024-07-31 12:42:12 +00:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
ctx context.Context
|
|
|
|
req *action.Target
|
|
|
|
want *resource_object.Details
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "missing permission",
|
|
|
|
ctx: Tester.WithAuthorization(context.Background(), integration.OrgOwner),
|
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty name",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: "",
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty type",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
TargetType: nil,
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty webhook url",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
TargetType: &action.Target_RestWebhook{
|
|
|
|
RestWebhook: &action.SetRESTWebhook{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty request response url",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
TargetType: &action.Target_RestCall{
|
|
|
|
RestCall: &action.SetRESTCall{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty timeout",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestWebhook{
|
|
|
|
RestWebhook: &action.SetRESTWebhook{},
|
|
|
|
},
|
|
|
|
Timeout: nil,
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "async, ok",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestAsync{
|
|
|
|
RestAsync: &action.SetRESTAsync{},
|
|
|
|
},
|
|
|
|
Timeout: durationpb.New(10 * time.Second),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "webhook, ok",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestWebhook{
|
|
|
|
RestWebhook: &action.SetRESTWebhook{
|
|
|
|
InterruptOnError: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timeout: durationpb.New(10 * time.Second),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "webhook, interrupt on error, ok",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestWebhook{
|
|
|
|
RestWebhook: &action.SetRESTWebhook{
|
|
|
|
InterruptOnError: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timeout: durationpb.New(10 * time.Second),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "call, ok",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestCall{
|
|
|
|
RestCall: &action.SetRESTCall{
|
|
|
|
InterruptOnError: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timeout: durationpb.New(10 * time.Second),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
name: "call, interruptOnError, ok",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.Target{
|
|
|
|
Name: fmt.Sprint(time.Now().UnixNano() + 1),
|
|
|
|
Endpoint: "https://example.com",
|
|
|
|
TargetType: &action.Target_RestCall{
|
|
|
|
RestCall: &action.SetRESTCall{
|
|
|
|
InterruptOnError: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timeout: durationpb.New(10 * time.Second),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-08-14 14:18:14 +00:00
|
|
|
got, err := Tester.Client.ActionV3Alpha.CreateTarget(tt.ctx, &action.CreateTargetRequest{Target: tt.req})
|
2024-07-31 12:42:12 +00:00
|
|
|
if tt.wantErr {
|
|
|
|
require.Error(t, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
integration.AssertResourceDetails(t, tt.want, got.Details)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestServer_PatchTarget(t *testing.T) {
|
2024-08-12 20:32:01 +00:00
|
|
|
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
|
|
|
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
2024-07-31 12:42:12 +00:00
|
|
|
type args struct {
|
|
|
|
ctx context.Context
|
|
|
|
req *action.PatchTargetRequest
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
prepare func(request *action.PatchTargetRequest) error
|
|
|
|
args args
|
|
|
|
want *resource_object.Details
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "missing permission",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: Tester.WithAuthorization(context.Background(), integration.OrgOwner),
|
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
Name: gu.Ptr(fmt.Sprint(time.Now().UnixNano() + 1)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not existing",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
|
|
|
request.Id = "notexisting"
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
Name: gu.Ptr(fmt.Sprint(time.Now().UnixNano() + 1)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change name, ok",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
Name: gu.Ptr(fmt.Sprint(time.Now().UnixNano() + 1)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change type, ok",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
TargetType: &action.PatchTarget_RestCall{
|
|
|
|
RestCall: &action.SetRESTCall{
|
|
|
|
InterruptOnError: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change url, ok",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
Endpoint: gu.Ptr("https://example.com/hooks/new"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change timeout, ok",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
Timeout: durationpb.New(20 * time.Second),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change type async, ok",
|
|
|
|
prepare: func(request *action.PatchTargetRequest) error {
|
2024-08-12 20:32:01 +00:00
|
|
|
targetID := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeAsync, false).GetDetails().GetId()
|
2024-07-31 12:42:12 +00:00
|
|
|
request.Id = targetID
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
args: args{
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.PatchTargetRequest{
|
|
|
|
Target: &action.PatchTarget{
|
|
|
|
TargetType: &action.PatchTarget_RestAsync{
|
|
|
|
RestAsync: &action.SetRESTAsync{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
err := tt.prepare(tt.args.req)
|
|
|
|
require.NoError(t, err)
|
|
|
|
// We want to have the same response no matter how often we call the function
|
2024-08-14 14:18:14 +00:00
|
|
|
Tester.Client.ActionV3Alpha.PatchTarget(tt.args.ctx, tt.args.req)
|
|
|
|
got, err := Tester.Client.ActionV3Alpha.PatchTarget(tt.args.ctx, tt.args.req)
|
2024-07-31 12:42:12 +00:00
|
|
|
if tt.wantErr {
|
|
|
|
require.Error(t, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
integration.AssertResourceDetails(t, tt.want, got.Details)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestServer_DeleteTarget(t *testing.T) {
|
2024-08-12 20:32:01 +00:00
|
|
|
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
|
|
|
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
|
|
|
target := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://example.com", domain.TargetTypeWebhook, false)
|
2024-07-31 12:42:12 +00:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
ctx context.Context
|
|
|
|
req *action.DeleteTargetRequest
|
|
|
|
want *resource_object.Details
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "missing permission",
|
|
|
|
ctx: Tester.WithAuthorization(context.Background(), integration.OrgOwner),
|
|
|
|
req: &action.DeleteTargetRequest{
|
|
|
|
Id: target.GetDetails().GetId(),
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty id",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.DeleteTargetRequest{
|
|
|
|
Id: "",
|
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "delete target",
|
2024-08-12 20:32:01 +00:00
|
|
|
ctx: isolatedIAMOwnerCTX,
|
2024-07-31 12:42:12 +00:00
|
|
|
req: &action.DeleteTargetRequest{
|
|
|
|
Id: target.GetDetails().GetId(),
|
|
|
|
},
|
|
|
|
want: &resource_object.Details{
|
2024-08-12 20:32:01 +00:00
|
|
|
Changed: timestamppb.Now(),
|
2024-07-31 12:42:12 +00:00
|
|
|
Owner: &object.Owner{
|
|
|
|
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
2024-08-12 20:32:01 +00:00
|
|
|
Id: instanceID,
|
2024-07-31 12:42:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-08-14 14:18:14 +00:00
|
|
|
got, err := Tester.Client.ActionV3Alpha.DeleteTarget(tt.ctx, tt.req)
|
2024-07-31 12:42:12 +00:00
|
|
|
if tt.wantErr {
|
|
|
|
require.Error(t, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
integration.AssertResourceDetails(t, tt.want, got.Details)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|