fix: update userschema api to v3alpha definition (#8511)

# Which Problems Are Solved

UserSchema API is currently not completely as defined for v3alpha.

# How the Problems Are Solved

Update the protos and integration tests.

# Additional Changes

None

# Additional Context

None
This commit is contained in:
Stefan Benz
2024-09-02 13:24:15 +02:00
committed by GitHub
parent bbdf9dbb20
commit a9eb50321c
7 changed files with 242 additions and 212 deletions

View File

@@ -3,6 +3,8 @@ package userschema
import (
"context"
"github.com/muhlemmer/gu"
"github.com/zitadel/zitadel/internal/api/authz"
resource_object "github.com/zitadel/zitadel/internal/api/grpc/resources/object/v3alpha"
"github.com/zitadel/zitadel/internal/command"
@@ -102,20 +104,28 @@ func createUserSchemaToCommand(req *schema.CreateUserSchemaRequest, resourceOwne
}
func patchUserSchemaToCommand(req *schema.PatchUserSchemaRequest, resourceOwner string) (*command.ChangeUserSchema, error) {
schema, err := req.GetSchema().MarshalJSON()
schema, err := req.GetUserSchema().GetSchema().MarshalJSON()
if err != nil {
return nil, err
}
var ty *string
if req.GetUserSchema() != nil && req.GetUserSchema().GetType() != "" {
ty = gu.Ptr(req.GetUserSchema().GetType())
}
return &command.ChangeUserSchema{
ID: req.GetId(),
ResourceOwner: resourceOwner,
Type: req.Type,
Type: ty,
Schema: schema,
PossibleAuthenticators: authenticatorsToDomain(req.GetPossibleAuthenticators()),
PossibleAuthenticators: authenticatorsToDomain(req.GetUserSchema().GetPossibleAuthenticators()),
}, nil
}
func authenticatorsToDomain(authenticators []schema.AuthenticatorType) []domain.AuthenticatorType {
if authenticators == nil {
return nil
}
types := make([]domain.AuthenticatorType, len(authenticators))
for i, authenticator := range authenticators {
types[i] = authenticatorTypeToDomain(authenticator)