mirror of
https://github.com/zitadel/zitadel.git
synced 2025-11-14 22:04:22 +00:00
feat: add action v2 execution on requests and responses (#7637)
* feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: split request and response logic to handle the different context information * feat: split request and response logic to handle the different context information * fix: integration test * fix: import alias * fix: refactor execution package * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * docs: basic documentation for executions and targets * fix: change order for interceptors * fix: merge back origin/main * fix: change target definition command and query side (#7735) * fix: change target definition command and query side * fix: correct refactoring name changes * fix: correct refactoring name changes * fix: changing execution defintion with target list and type * fix: changing execution definition with target list and type * fix: add back search queries for target and include * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * docs: add example to actions v2 * docs: add example to actions v2 * fix: correct integration tests on query for executions * fix: add separate event for execution v2 as content changed * fix: add separate event for execution v2 as content changed * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com> * fix: added review comment changes * fix: added review comment changes * Update internal/api/grpc/server/middleware/execution_interceptor.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
@@ -27,55 +27,64 @@ func Test_createTargetToCommand(t *testing.T) {
|
||||
args: args{nil},
|
||||
want: &command.AddTarget{
|
||||
Name: "",
|
||||
URL: "",
|
||||
Endpoint: "",
|
||||
Timeout: 0,
|
||||
Async: false,
|
||||
InterruptOnError: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (async webhook)",
|
||||
name: "all fields (webhook)",
|
||||
args: args{&action.CreateTargetRequest{
|
||||
Name: "target 1",
|
||||
Name: "target 1",
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.SetRESTWebhook{
|
||||
Url: "https://example.com/hooks/1",
|
||||
},
|
||||
RestWebhook: &action.SetRESTWebhook{},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
ExecutionType: &action.CreateTargetRequest_IsAsync{
|
||||
IsAsync: true,
|
||||
},
|
||||
}},
|
||||
want: &command.AddTarget{
|
||||
Name: "target 1",
|
||||
TargetType: domain.TargetTypeWebhook,
|
||||
URL: "https://example.com/hooks/1",
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
Timeout: 10 * time.Second,
|
||||
InterruptOnError: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (async)",
|
||||
args: args{&action.CreateTargetRequest{
|
||||
Name: "target 1",
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
TargetType: &action.CreateTargetRequest_RestAsync{
|
||||
RestAsync: &action.SetRESTAsync{},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
}},
|
||||
want: &command.AddTarget{
|
||||
Name: "target 1",
|
||||
TargetType: domain.TargetTypeAsync,
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
Timeout: 10 * time.Second,
|
||||
Async: true,
|
||||
InterruptOnError: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (interrupting response)",
|
||||
args: args{&action.CreateTargetRequest{
|
||||
Name: "target 1",
|
||||
TargetType: &action.CreateTargetRequest_RestRequestResponse{
|
||||
RestRequestResponse: &action.SetRESTRequestResponse{
|
||||
Url: "https://example.com/hooks/1",
|
||||
Name: "target 1",
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.SetRESTCall{
|
||||
InterruptOnError: true,
|
||||
},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
ExecutionType: &action.CreateTargetRequest_InterruptOnError{
|
||||
InterruptOnError: true,
|
||||
},
|
||||
}},
|
||||
want: &command.AddTarget{
|
||||
Name: "target 1",
|
||||
TargetType: domain.TargetTypeRequestResponse,
|
||||
URL: "https://example.com/hooks/1",
|
||||
TargetType: domain.TargetTypeCall,
|
||||
Endpoint: "https://example.com/hooks/1",
|
||||
Timeout: 10 * time.Second,
|
||||
Async: false,
|
||||
InterruptOnError: true,
|
||||
},
|
||||
},
|
||||
@@ -105,80 +114,108 @@ func Test_updateTargetToCommand(t *testing.T) {
|
||||
{
|
||||
name: "all fields nil",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: nil,
|
||||
TargetType: nil,
|
||||
Timeout: nil,
|
||||
ExecutionType: nil,
|
||||
Name: nil,
|
||||
TargetType: nil,
|
||||
Timeout: nil,
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: nil,
|
||||
TargetType: nil,
|
||||
URL: nil,
|
||||
Endpoint: nil,
|
||||
Timeout: nil,
|
||||
Async: nil,
|
||||
InterruptOnError: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields empty",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(""),
|
||||
TargetType: nil,
|
||||
Timeout: durationpb.New(0),
|
||||
ExecutionType: nil,
|
||||
Name: gu.Ptr(""),
|
||||
TargetType: nil,
|
||||
Timeout: durationpb.New(0),
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: gu.Ptr(""),
|
||||
TargetType: nil,
|
||||
URL: nil,
|
||||
Endpoint: nil,
|
||||
Timeout: gu.Ptr(0 * time.Second),
|
||||
Async: nil,
|
||||
InterruptOnError: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (async webhook)",
|
||||
name: "all fields (webhook)",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: gu.Ptr("target 1"),
|
||||
Name: gu.Ptr("target 1"),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
TargetType: &action.UpdateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.SetRESTWebhook{
|
||||
Url: "https://example.com/hooks/1",
|
||||
InterruptOnError: false,
|
||||
},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
ExecutionType: &action.UpdateTargetRequest_IsAsync{
|
||||
IsAsync: true,
|
||||
},
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: gu.Ptr("target 1"),
|
||||
TargetType: gu.Ptr(domain.TargetTypeWebhook),
|
||||
URL: gu.Ptr("https://example.com/hooks/1"),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
Timeout: gu.Ptr(10 * time.Second),
|
||||
InterruptOnError: gu.Ptr(false),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (webhook interrupt)",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: gu.Ptr("target 1"),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
TargetType: &action.UpdateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.SetRESTWebhook{
|
||||
InterruptOnError: true,
|
||||
},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: gu.Ptr("target 1"),
|
||||
TargetType: gu.Ptr(domain.TargetTypeWebhook),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
Timeout: gu.Ptr(10 * time.Second),
|
||||
InterruptOnError: gu.Ptr(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (async)",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: gu.Ptr("target 1"),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
TargetType: &action.UpdateTargetRequest_RestAsync{
|
||||
RestAsync: &action.SetRESTAsync{},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: gu.Ptr("target 1"),
|
||||
TargetType: gu.Ptr(domain.TargetTypeAsync),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
Timeout: gu.Ptr(10 * time.Second),
|
||||
Async: gu.Ptr(true),
|
||||
InterruptOnError: gu.Ptr(false),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all fields (interrupting response)",
|
||||
args: args{&action.UpdateTargetRequest{
|
||||
Name: gu.Ptr("target 1"),
|
||||
TargetType: &action.UpdateTargetRequest_RestRequestResponse{
|
||||
RestRequestResponse: &action.SetRESTRequestResponse{
|
||||
Url: "https://example.com/hooks/1",
|
||||
Name: gu.Ptr("target 1"),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
TargetType: &action.UpdateTargetRequest_RestCall{
|
||||
RestCall: &action.SetRESTCall{
|
||||
InterruptOnError: true,
|
||||
},
|
||||
},
|
||||
Timeout: durationpb.New(10 * time.Second),
|
||||
ExecutionType: &action.UpdateTargetRequest_InterruptOnError{
|
||||
InterruptOnError: true,
|
||||
},
|
||||
}},
|
||||
want: &command.ChangeTarget{
|
||||
Name: gu.Ptr("target 1"),
|
||||
TargetType: gu.Ptr(domain.TargetTypeRequestResponse),
|
||||
URL: gu.Ptr("https://example.com/hooks/1"),
|
||||
TargetType: gu.Ptr(domain.TargetTypeCall),
|
||||
Endpoint: gu.Ptr("https://example.com/hooks/1"),
|
||||
Timeout: gu.Ptr(10 * time.Second),
|
||||
Async: gu.Ptr(false),
|
||||
InterruptOnError: gu.Ptr(true),
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user