feat: instance domain APIs with relational tables (#11051)

# Which Problems Are Solved

This PR implements the endpoints listed in
https://github.com/zitadel/zitadel/issues/10444 .

# How the Problems Are Solved

The implementation follows the same pattern as the Instance one. The
`Add` and `Remove` are implementing the `Commander` interface, while
`List` Domains endpoints are implementing the `Querier` interace.

The PR adds also some forgotten calls to the relational logic for the
Instance API. The commits are identifiable by the label `instance:`
prepended to them. This is the complete list: bafce01b0 , 6fe7257ab ,
e27bc9c34 , 8133ede73 , fde667953 , a3e1135ed , ee1a6f9c1

# Additional Context

- Closes #10444

---------

Co-authored-by: Elio Bischof <[email protected]>
Co-authored-by: Lebogang Phoshoko <[email protected]>
Co-authored-by: Wim Van Laer <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Gayathri Vijayan <[email protected]>
This commit is contained in:
Marco A.
2025-12-17 12:01:09 +01:00
committed by GitHub
co-authored by Elio Bischof Lebogang Phoshoko Wim Van Laer Max Peintner Gayathri Vijayan
parent d79bfe6eba
commit b339a3e696
49 changed files with 5670 additions and 1466 deletions
+30 -4
View File
@@ -34,13 +34,13 @@ func TestGetInstanceCommand_Validate(t *testing.T) {
name: "empty instance id, error",
inputInstanceID: "",
ctx: context.Background(),
expectedError: zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "invalid instance ID"),
expectedError: zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "Errors.Instance.ID"),
},
{
name: "whitespace instance id, error",
inputInstanceID: " ",
ctx: context.Background(),
expectedError: zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "invalid instance ID"),
expectedError: zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "Errors.Instance.ID"),
},
{
name: "instance id mismatch, error",
@@ -62,7 +62,7 @@ func TestGetInstanceCommand_Validate(t *testing.T) {
},
inputInstanceID: "instance1",
ctx: authz.NewMockContext("instance1", "", ""),
expectedError: zerrors.ThrowPermissionDenied(permissionErr, "DOM-Uq6b00", "permission denied"),
expectedError: zerrors.ThrowPermissionDenied(permissionErr, "DOM-Uq6b00", "Errors.PermissionDenied"),
},
{
name: "valid instance id, success",
@@ -107,6 +107,7 @@ func TestGetInstanceCommand_Execute(t *testing.T) {
ctx := authz.NewMockContext("inst-1", "org-1", gofakeit.UUID())
getErr := errors.New("get error")
notFoundErr := database.NewNoRowFoundError(nil)
tt := []struct {
testName string
@@ -141,7 +142,32 @@ func TestGetInstanceCommand_Execute(t *testing.T) {
return instanceRepo
},
inputInstanceID: "instance-1",
expectedError: getErr,
expectedError: zerrors.ThrowInternal(getErr, "DOM-lvsRce", "Errors.Instance.Get"),
},
{
testName: "when instance is not found should return not found error",
instanceRepo: func(ctrl *gomock.Controller) domain.InstanceRepository {
instanceRepo := domainmock.NewInstanceRepo(ctrl)
instanceRepo.EXPECT().
LoadDomains().
Times(1).
Return(instanceRepo)
instanceRepo.EXPECT().
Get(
gomock.Any(),
gomock.Any(),
dbmock.QueryOptions(database.WithCondition(
instanceRepo.IDCondition("instance-1"),
)),
).
Times(1).
Return(nil, notFoundErr)
return instanceRepo
},
inputInstanceID: "instance-1",
expectedError: zerrors.ThrowNotFound(notFoundErr, "DOM-QVrUwc", "Errors.Instance.NotFound"),
},
{
testName: "when retrieving instance succeeds should set instance on struct and return no error",