feat(v3alpha): write actions (#8225)

# 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

- **Breaking**: The current v3alpha actions APIs are removed. This is
breaking.
- **Resource Namespace**: New v3alpha actions APIs for targets and
executions are added under the namespace /resources.
- **Feature Flag**: New v3alpha actions APIs still have to be activated
using the actions feature flag
- **Reduced Executions Overhead**: Executions are managed similar to
settings according to the new API design: an empty list of targets
basically makes an execution a Noop. So a single method, SetExecution is
enough to cover all use cases. Noop executions are not returned in
future search requests.
- **Compatibility**: The executions created with previous v3alpha APIs
are still available to be managed with the new executions API.

# Additional Changes

- Removed integration tests which test executions but rely on readable
targets. They are added again with #8169

# Additional Context

Closes #8168
This commit is contained in:
Elio Bischof
2024-07-31 14:42:12 +02:00
committed by GitHub
parent a1d24353db
commit cc3ec1e2a7
50 changed files with 2822 additions and 5570 deletions

View File

@@ -9,6 +9,9 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
resources_object "github.com/zitadel/zitadel/pkg/grpc/resources/object/v3alpha"
settings_object "github.com/zitadel/zitadel/pkg/grpc/settings/object/v3alpha"
)
// Details is the interface that covers both v1 and v2 proto generated object details.
@@ -63,6 +66,31 @@ func AssertDetails[D Details, M DetailsMsg[D]](t testing.TB, expected, actual M)
assert.Equal(t, wantDetails.GetResourceOwner(), gotDetails.GetResourceOwner())
}
func AssertResourceDetails(t testing.TB, expected *resources_object.Details, actual *resources_object.Details) {
assert.NotZero(t, actual.GetSequence())
if expected.GetChangeDate() != nil {
wantChangeDate := time.Now()
gotChangeDate := actual.GetChangeDate().AsTime()
assert.WithinRange(t, gotChangeDate, wantChangeDate.Add(-time.Minute), wantChangeDate.Add(time.Minute))
}
assert.Equal(t, expected.GetOwner(), actual.GetOwner())
assert.NotEmpty(t, actual.GetId())
}
func AssertSettingsDetails(t testing.TB, expected *settings_object.Details, actual *settings_object.Details) {
assert.NotZero(t, actual.GetSequence())
if expected.GetChangeDate() != nil {
wantChangeDate := time.Now()
gotChangeDate := actual.GetChangeDate().AsTime()
assert.WithinRange(t, gotChangeDate, wantChangeDate.Add(-time.Minute), wantChangeDate.Add(time.Minute))
}
assert.Equal(t, expected.GetOwner(), actual.GetOwner())
}
func AssertListDetails[L ListDetails, D ListDetailsMsg[L]](t testing.TB, expected, actual D) {
wantDetails, gotDetails := expected.GetDetails(), actual.GetDetails()
var nilDetails L