mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-07 06:42:15 +00:00
feat(v3alpha): read actions (#8357)
# Which Problems Are Solved The current v3alpha actions APIs don't exactly adhere to the [new resources API design](https://zitadel.com/docs/apis/v3#standard-resources). # How the Problems Are Solved - **Improved ID access**: The aggregate ID is added to the resource details object, so accessing resource IDs and constructing proto messages for resources is easier - **Explicit Instances**: Optionally, the instance can be explicitly given in each request - **Pagination**: A default search limit and a max search limit are added to the defaults.yaml. They apply to the new v3 APIs (currently only actions). The search query defaults are changed to ascending by creation date, because this makes the pagination results the most deterministic. The creation date is also added to the object details. The bug with updated creation dates is fixed for executions and targets. - **Removed Sequences**: Removed Sequence from object details and ProcessedSequence from search details # Additional Changes Object details IDs are checked in unit test only if an empty ID is expected. Centralizing the details check also makes this internal object more flexible for future evolutions. # Additional Context - Closes #8169 - Depends on https://github.com/zitadel/zitadel/pull/8225 --------- Co-authored-by: Silvan <[email protected]> Co-authored-by: Stefan Benz <[email protected]>
This commit is contained in:
co-authored by
Silvan
Stefan Benz
parent
18c3f574a9
commit
042c438813
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/integration"
|
||||
object "github.com/zitadel/zitadel/pkg/grpc/object/v3alpha"
|
||||
action "github.com/zitadel/zitadel/pkg/grpc/resources/action/v3alpha"
|
||||
settings_object "github.com/zitadel/zitadel/pkg/grpc/settings/object/v3alpha"
|
||||
resource_object "github.com/zitadel/zitadel/pkg/grpc/resources/object/v3alpha"
|
||||
)
|
||||
|
||||
func executionTargetsSingleTarget(id string) []*action.ExecutionTargetType {
|
||||
@@ -25,8 +25,9 @@ func executionTargetsSingleInclude(include *action.Condition) []*action.Executio
|
||||
}
|
||||
|
||||
func TestServer_SetExecution_Request(t *testing.T) {
|
||||
ensureFeatureEnabled(t)
|
||||
targetResp := Tester.CreateTarget(CTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
||||
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
||||
targetResp := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -51,7 +52,7 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no condition, error",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -66,7 +67,7 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "method, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -85,7 +86,7 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "method, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -101,18 +102,18 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "service, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -131,7 +132,7 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "service, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -147,18 +148,18 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -174,11 +175,11 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -187,8 +188,8 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// We want to have the same response no matter how often we call the function
|
||||
Client.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Client.SetExecution(tt.ctx, tt.req)
|
||||
Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
@@ -196,7 +197,7 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
integration.AssertSettingsDetails(t, tt.want.Details, got.Details)
|
||||
integration.AssertResourceDetails(t, tt.want.Details, got.Details)
|
||||
|
||||
// cleanup to not impact other requests
|
||||
Tester.DeleteExecution(tt.ctx, t, tt.req.GetCondition())
|
||||
@@ -205,8 +206,9 @@ func TestServer_SetExecution_Request(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
ensureFeatureEnabled(t)
|
||||
targetResp := Tester.CreateTarget(CTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
||||
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
||||
targetResp := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
executionCond := &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
Request: &action.RequestExecution{
|
||||
@@ -216,7 +218,7 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
Tester.SetExecution(CTX, t,
|
||||
Tester.SetExecution(isolatedIAMOwnerCTX, t,
|
||||
executionCond,
|
||||
executionTargetsSingleTarget(targetResp.GetDetails().GetId()),
|
||||
)
|
||||
@@ -230,7 +232,7 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
Tester.SetExecution(CTX, t,
|
||||
Tester.SetExecution(isolatedIAMOwnerCTX, t,
|
||||
circularExecutionService,
|
||||
executionTargetsSingleInclude(executionCond),
|
||||
)
|
||||
@@ -243,7 +245,7 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
Tester.SetExecution(CTX, t,
|
||||
Tester.SetExecution(isolatedIAMOwnerCTX, t,
|
||||
circularExecutionMethod,
|
||||
executionTargetsSingleInclude(circularExecutionService),
|
||||
)
|
||||
@@ -257,7 +259,7 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "method, circular error",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: circularExecutionService,
|
||||
Execution: &action.Execution{
|
||||
@@ -268,7 +270,7 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "method, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -280,23 +282,22 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Execution: &action.Execution{
|
||||
|
||||
Targets: executionTargetsSingleInclude(executionCond),
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "service, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Request{
|
||||
@@ -308,16 +309,15 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Execution: &action.Execution{
|
||||
|
||||
Targets: executionTargetsSingleInclude(executionCond),
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -326,15 +326,15 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// We want to have the same response no matter how often we call the function
|
||||
Client.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Client.SetExecution(tt.ctx, tt.req)
|
||||
Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
integration.AssertSettingsDetails(t, tt.want.Details, got.Details)
|
||||
integration.AssertResourceDetails(t, tt.want.Details, got.Details)
|
||||
|
||||
// cleanup to not impact other requests
|
||||
Tester.DeleteExecution(tt.ctx, t, tt.req.GetCondition())
|
||||
@@ -343,8 +343,9 @@ func TestServer_SetExecution_Request_Include(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_SetExecution_Response(t *testing.T) {
|
||||
ensureFeatureEnabled(t)
|
||||
targetResp := Tester.CreateTarget(CTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
||||
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
||||
targetResp := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -369,7 +370,7 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no condition, error",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -384,7 +385,7 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "method, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -403,7 +404,7 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "method, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -419,18 +420,18 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "service, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -449,7 +450,7 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "service, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -465,18 +466,18 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -492,11 +493,11 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -505,15 +506,15 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// We want to have the same response no matter how often we call the function
|
||||
Client.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Client.SetExecution(tt.ctx, tt.req)
|
||||
Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
integration.AssertSettingsDetails(t, tt.want.Details, got.Details)
|
||||
integration.AssertResourceDetails(t, tt.want.Details, got.Details)
|
||||
|
||||
// cleanup to not impact other requests
|
||||
Tester.DeleteExecution(tt.ctx, t, tt.req.GetCondition())
|
||||
@@ -522,8 +523,9 @@ func TestServer_SetExecution_Response(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_SetExecution_Event(t *testing.T) {
|
||||
ensureFeatureEnabled(t)
|
||||
targetResp := Tester.CreateTarget(CTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
||||
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
||||
targetResp := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -550,7 +552,7 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no condition, error",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -568,7 +570,7 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
|
||||
{
|
||||
name: "event, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -586,7 +588,7 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
*/
|
||||
{
|
||||
name: "event, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -602,11 +604,11 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -616,7 +618,7 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
|
||||
{
|
||||
name: "group, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -634,7 +636,7 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
*/
|
||||
{
|
||||
name: "group, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -650,18 +652,18 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Event{
|
||||
@@ -677,11 +679,11 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -690,15 +692,15 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// We want to have the same response no matter how often we call the function
|
||||
Client.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Client.SetExecution(tt.ctx, tt.req)
|
||||
Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
integration.AssertSettingsDetails(t, tt.want.Details, got.Details)
|
||||
integration.AssertResourceDetails(t, tt.want.Details, got.Details)
|
||||
|
||||
// cleanup to not impact other requests
|
||||
Tester.DeleteExecution(tt.ctx, t, tt.req.GetCondition())
|
||||
@@ -707,8 +709,9 @@ func TestServer_SetExecution_Event(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_SetExecution_Function(t *testing.T) {
|
||||
ensureFeatureEnabled(t)
|
||||
targetResp := Tester.CreateTarget(CTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
_, instanceID, _, isolatedIAMOwnerCTX := Tester.UseIsolatedInstance(t, IAMOwnerCTX, SystemCTX)
|
||||
ensureFeatureEnabled(t, isolatedIAMOwnerCTX)
|
||||
targetResp := Tester.CreateTarget(isolatedIAMOwnerCTX, t, "", "https://notexisting", domain.TargetTypeWebhook, false)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -733,7 +736,7 @@ func TestServer_SetExecution_Function(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no condition, error",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Response{
|
||||
@@ -748,7 +751,7 @@ func TestServer_SetExecution_Function(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "function, not existing",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Function{
|
||||
@@ -763,7 +766,7 @@ func TestServer_SetExecution_Function(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "function, ok",
|
||||
ctx: CTX,
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.SetExecutionRequest{
|
||||
Condition: &action.Condition{
|
||||
ConditionType: &action.Condition_Function{
|
||||
@@ -775,11 +778,11 @@ func TestServer_SetExecution_Function(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &action.SetExecutionResponse{
|
||||
Details: &settings_object.Details{
|
||||
ChangeDate: timestamppb.Now(),
|
||||
Details: &resource_object.Details{
|
||||
Changed: timestamppb.Now(),
|
||||
Owner: &object.Owner{
|
||||
Type: object.OwnerType_OWNER_TYPE_INSTANCE,
|
||||
Id: Tester.Instance.InstanceID(),
|
||||
Id: instanceID,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -788,15 +791,15 @@ func TestServer_SetExecution_Function(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// We want to have the same response no matter how often we call the function
|
||||
Client.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Client.SetExecution(tt.ctx, tt.req)
|
||||
Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
got, err := Tester.Client.ActionV3.SetExecution(tt.ctx, tt.req)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
integration.AssertSettingsDetails(t, tt.want.Details, got.Details)
|
||||
integration.AssertResourceDetails(t, tt.want.Details, got.Details)
|
||||
|
||||
// cleanup to not impact other requests
|
||||
Tester.DeleteExecution(tt.ctx, t, tt.req.GetCondition())
|
||||
|
||||
Reference in New Issue
Block a user