fix(machine): delete domain policy dependency and restructure functions (#4605)

* fix(machine): delete domain policy dependency and restructure functions

* fix(machine): delete domain policy dependency and restructure functions

* fix(machine): move check for username and name

* fix: correct unit test for machine

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Stefan Benz
2022-10-26 09:39:56 +01:00
committed by GitHub
parent 27e7dc68a8
commit 71fb5c526f
5 changed files with 218 additions and 144 deletions

View File

@@ -271,17 +271,14 @@ func (s *Server) ImportHumanUser(ctx context.Context, req *mgmt_pb.ImportHumanUs
}
func (s *Server) AddMachineUser(ctx context.Context, req *mgmt_pb.AddMachineUserRequest) (*mgmt_pb.AddMachineUserResponse, error) {
machine, err := s.command.AddMachine(ctx, authz.GetCtxData(ctx).OrgID, AddMachineUserRequestToDomain(req))
machine := AddMachineUserRequestToCommand(req, authz.GetCtxData(ctx).OrgID)
objectDetails, err := s.command.AddMachine(ctx, machine)
if err != nil {
return nil, err
}
return &mgmt_pb.AddMachineUserResponse{
UserId: machine.AggregateID,
Details: obj_grpc.AddToDetailsPb(
machine.Sequence,
machine.ChangeDate,
machine.ResourceOwner,
),
UserId: machine.AggregateID,
Details: obj_grpc.DomainToChangeDetailsPb(objectDetails),
}, nil
}
@@ -682,16 +679,13 @@ func (s *Server) RemoveHumanPasswordless(ctx context.Context, req *mgmt_pb.Remov
}
func (s *Server) UpdateMachine(ctx context.Context, req *mgmt_pb.UpdateMachineRequest) (*mgmt_pb.UpdateMachineResponse, error) {
machine, err := s.command.ChangeMachine(ctx, UpdateMachineRequestToDomain(ctx, req))
machine := UpdateMachineRequestToCommand(req, authz.GetCtxData(ctx).OrgID)
objectDetails, err := s.command.ChangeMachine(ctx, machine)
if err != nil {
return nil, err
}
return &mgmt_pb.UpdateMachineResponse{
Details: obj_grpc.ChangeToDetailsPb(
machine.Sequence,
machine.ChangeDate,
machine.ResourceOwner,
),
Details: obj_grpc.DomainToChangeDetailsPb(objectDetails),
}, nil
}