mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-28 23:18:54 +00:00
feat(domain): introduce error slugs (#12030)
# Which Problems Are Solved As part of https://github.com/zitadel/zitadel/issues/11917 we want to introduce error slugs so (API) clients can rely on stable, machine-readable errors and act accordingly. # How the Problems Are Solved - Added a `NewSlug` helper function in the domain package. - Added `ErrorDetails` to the `ZitadelError` - Added an `zitadel.error.v2.ErrorDetail` proto message - Updated the connectRPC error interceptor to map new slug based errors to the new `ErrorDetail` - Defined some common slugs and error functions like internal errors - Defined (session) specific slugs used in the `DeleteSession` and `CheckUser` functions and replaced old implementations - Updated integration tests to check specific errors if the relation database feature is enabled - Updated doc and guideline to reflect the latest changes and decisions - Updated DeleteSession endpoint API to list possible slugs # Additional Changes None # Additional Context - closes #11957 --------- Co-authored-by: Wim Van Laer <[email protected]>
This commit is contained in:
co-authored by
Wim Van Laer
parent
5c9361f6c7
commit
a2bf528ca0
@@ -16,7 +16,6 @@ import (
|
||||
noopdb "github.com/zitadel/zitadel/backend/v3/storage/database/dialect/noop"
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
zdomain "github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
func TestDeleteSessionCommand_Validate(t *testing.T) {
|
||||
@@ -44,7 +43,7 @@ func TestDeleteSessionCommand_Validate(t *testing.T) {
|
||||
sessionID: "",
|
||||
},
|
||||
fields: fields{},
|
||||
expectedError: zerrors.ThrowInvalidArgument(nil, domain.ErrIDMissing, "Errors.IDMissing"),
|
||||
expectedError: domain.ErrIDMissing(),
|
||||
},
|
||||
{
|
||||
name: "when sessionID is provided must validate successfully",
|
||||
@@ -208,7 +207,7 @@ func TestDeleteSessionCommand_Execute(t *testing.T) {
|
||||
mustCheckPermission: true,
|
||||
},
|
||||
res: res{
|
||||
error: new(database.PermissionError),
|
||||
error: domain.ErrAuthMissingPermission(nil, "", domain.SessionDeletePermission),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -230,7 +229,7 @@ func TestDeleteSessionCommand_Execute(t *testing.T) {
|
||||
sessionID: "session-1",
|
||||
},
|
||||
res: res{
|
||||
error: zerrors.ThrowInternalf(nil, domain.ErrMoreThanOneRowAffected, "expected 1 session to be deleted, got %d", 2),
|
||||
error: domain.ErrMoreThanOneRowAffected("expected 1 session to be deleted, got 2", 2),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -339,7 +338,7 @@ func mockSessionTokenDecryptor(expectedSessionToken, returnSessionID, returnSess
|
||||
return func(t *testing.T) domain.SessionTokenDecryptor {
|
||||
return func(ctx context.Context, sessionToken string) (sessionID, tokenID string, err error) {
|
||||
if sessionToken != expectedSessionToken {
|
||||
return "", "", zerrors.ThrowInvalidArgumentf(nil, "SESS-S3gq1", "Errors.Session.TokenInvalid")
|
||||
return "", "", domain.ErrSessionTokenInvalid(nil)
|
||||
}
|
||||
return returnSessionID, returnSessionToken, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user