diff --git a/api/proto/fachstelleregistration.model.proto b/api/proto/fachstelleregistration.model.proto index 7ade3294fdd6e7bdf164fc784574f0d702eba655..928fd728c4a79a3c8933803925d38a7fef06f2f3 100644 --- a/api/proto/fachstelleregistration.model.proto +++ b/api/proto/fachstelleregistration.model.proto @@ -30,14 +30,6 @@ package de.ozgcloud.fachstellenproxy; option go_package = "de.ozgcloud.fachstellenproxy"; message GrpcFachstelleRegistrationRequest { - GrpcFachstelle fachstelle = 1; -} - -message GrpcFachstelleRegistrationResponse { - -} - -message GrpcFachstelle { string mukId = 1; string firmenName = 2; string rechtsform = 3; @@ -46,4 +38,8 @@ message GrpcFachstelle { string registerArt = 6; string emailAdresse = 7; string anschrift = 8; +} + +message GrpcFachstelleRegistrationResponse { + } \ No newline at end of file diff --git a/internal/mock/grpc_server.go b/internal/mock/grpc_server.go index bb37e171ab62ffcda7668b16baf5c484d334a8e8..404336c8351a10678f7ef39e7c8d47c640727c32 100644 --- a/internal/mock/grpc_server.go +++ b/internal/mock/grpc_server.go @@ -49,16 +49,16 @@ type registrationServer struct { } func (s *registrationServer) Register(_ context.Context, in *pb.GrpcFachstelleRegistrationRequest) (*pb.GrpcFachstelleRegistrationResponse, error) { - if in.Fachstelle == nil { - return nil, status.Error(codes.InvalidArgument, "fachstelle is missing") + if in.MukId == "" { + return nil, status.Error(codes.InvalidArgument, "mukId is missing") } - if in.Fachstelle.MukId == "conflictMukId" { - return nil, status.Error(codes.AlreadyExists, "conflict MukId") - } else if in.Fachstelle.MukId == "unavailableMukId" { - return nil, status.Error(codes.Unavailable, "unavailable MukId") - } else if in.Fachstelle.MukId == "erroneousMukId" { - return nil, status.Error(codes.Internal, "erroneous MukId") + if in.MukId == "conflictMukId" { + return nil, status.Error(codes.AlreadyExists, "conflict mukId") + } else if in.MukId == "unavailableMukId" { + return nil, status.Error(codes.Unavailable, "unavailable mukId") + } else if in.MukId == "erroneousMukId" { + return nil, status.Error(codes.Internal, "erroneous mukId") } return &pb.GrpcFachstelleRegistrationResponse{}, nil diff --git a/internal/mock/grpc_server_test.go b/internal/mock/grpc_server_test.go index b9ab84c0db470f438181cb9121cbc8e0340189a4..808ca74fad0d8dc04af366ba8c1cfa4dfe002f00 100644 --- a/internal/mock/grpc_server_test.go +++ b/internal/mock/grpc_server_test.go @@ -67,7 +67,7 @@ func TestStartGrpcServer(t *testing.T) { client, cleanUp := setUpGrpcEnv() defer cleanUp() - resp, err := client.Register(context.Background(), &pb.GrpcFachstelleRegistrationRequest{Fachstelle: &pb.GrpcFachstelle{MukId: "testMukId"}}) + resp, err := client.Register(context.Background(), &pb.GrpcFachstelleRegistrationRequest{MukId: "testMukId"}) assert.NoError(t, err) assert.NotNil(t, resp) diff --git a/internal/server/handler_test.go b/internal/server/handler_test.go index 976134a1502454e94dfcac15caef383b24186d65..89f372cdf23d192216cd134b7499113e620f511b 100644 --- a/internal/server/handler_test.go +++ b/internal/server/handler_test.go @@ -46,7 +46,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) { mock.SetUpGrpcServer() SetUpHttpGateway() - jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) + jsonData := []byte(`{"mukId": "testMukId"}`) resp, err := http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData)) assert.NoError(t, err) @@ -102,19 +102,19 @@ func TestErrorHandler(t *testing.T) { }) t.Run("should have conflict error", func(t *testing.T) { - jsonData := []byte(`{"fachstelle": {"mukId": "conflictMukId"}}`) + jsonData := []byte(`{"mukId": "conflictMukId"}`) assertErroneousRequest(jsonData, http.StatusConflict) }) t.Run("should have unavailable error", func(t *testing.T) { - jsonData := []byte(`{"fachstelle": {"mukId": "unavailableMukId"}}`) + jsonData := []byte(`{"mukId": "unavailableMukId"}`) assertErroneousRequest(jsonData, http.StatusServiceUnavailable) }) t.Run("should have internal server error", func(t *testing.T) { - jsonData := []byte(`{"fachstelle": {"mukId": "erroneousMukId"}}`) + jsonData := []byte(`{"mukId": "erroneousMukId"}`) assertErroneousRequest(jsonData, http.StatusInternalServerError) }) diff --git a/internal/server/middleware_test.go b/internal/server/middleware_test.go index 90806e9ca0b4077e8383c3f1cb089f7fdfd0f70e..d6c48e4df4f3b1969145ece316481472a2c76d36 100644 --- a/internal/server/middleware_test.go +++ b/internal/server/middleware_test.go @@ -47,12 +47,12 @@ func TestRequestLoggingMiddleware(t *testing.T) { logger.BaseLogger.SetFlags(originalFlags) }() - jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) + jsonData := []byte(`{"mukId": "testMukId"}`) http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData)) logOutput := buf.String() - assert.Contains(t, logOutput, "received POST request for /api/fachstellen with body: {\"fachstelle\": {\"mukId\": \"testMukId\"}}") - assert.Contains(t, logOutput, "successfully handled POST request for /api/fachstellen with body: {\"fachstelle\": {\"mukId\": \"testMukId\"}}") + assert.Contains(t, logOutput, "received POST request for /api/fachstellen with body: {\"mukId\": \"testMukId\"}") + assert.Contains(t, logOutput, "successfully handled POST request for /api/fachstellen with body: {\"mukId\": \"testMukId\"}") }) t.Run("should not log request", func(t *testing.T) {