Skip to content
Snippets Groups Projects
Commit 1e7713ef authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6676 proxy adaption

parent a05c6a3d
No related branches found
No related tags found
No related merge requests found
...@@ -30,14 +30,6 @@ package de.ozgcloud.fachstellenproxy; ...@@ -30,14 +30,6 @@ package de.ozgcloud.fachstellenproxy;
option go_package = "de.ozgcloud.fachstellenproxy"; option go_package = "de.ozgcloud.fachstellenproxy";
message GrpcFachstelleRegistrationRequest { message GrpcFachstelleRegistrationRequest {
GrpcFachstelle fachstelle = 1;
}
message GrpcFachstelleRegistrationResponse {
}
message GrpcFachstelle {
string mukId = 1; string mukId = 1;
string firmenName = 2; string firmenName = 2;
string rechtsform = 3; string rechtsform = 3;
...@@ -47,3 +39,7 @@ message GrpcFachstelle { ...@@ -47,3 +39,7 @@ message GrpcFachstelle {
string emailAdresse = 7; string emailAdresse = 7;
string anschrift = 8; string anschrift = 8;
} }
message GrpcFachstelleRegistrationResponse {
}
\ No newline at end of file
...@@ -49,16 +49,16 @@ type registrationServer struct { ...@@ -49,16 +49,16 @@ type registrationServer struct {
} }
func (s *registrationServer) Register(_ context.Context, in *pb.GrpcFachstelleRegistrationRequest) (*pb.GrpcFachstelleRegistrationResponse, error) { func (s *registrationServer) Register(_ context.Context, in *pb.GrpcFachstelleRegistrationRequest) (*pb.GrpcFachstelleRegistrationResponse, error) {
if in.Fachstelle == nil { if in.MukId == "" {
return nil, status.Error(codes.InvalidArgument, "fachstelle is missing") return nil, status.Error(codes.InvalidArgument, "mukId is missing")
} }
if in.Fachstelle.MukId == "conflictMukId" { if in.MukId == "conflictMukId" {
return nil, status.Error(codes.AlreadyExists, "conflict MukId") return nil, status.Error(codes.AlreadyExists, "conflict mukId")
} else if in.Fachstelle.MukId == "unavailableMukId" { } else if in.MukId == "unavailableMukId" {
return nil, status.Error(codes.Unavailable, "unavailable MukId") return nil, status.Error(codes.Unavailable, "unavailable mukId")
} else if in.Fachstelle.MukId == "erroneousMukId" { } else if in.MukId == "erroneousMukId" {
return nil, status.Error(codes.Internal, "erroneous MukId") return nil, status.Error(codes.Internal, "erroneous mukId")
} }
return &pb.GrpcFachstelleRegistrationResponse{}, nil return &pb.GrpcFachstelleRegistrationResponse{}, nil
......
...@@ -67,7 +67,7 @@ func TestStartGrpcServer(t *testing.T) { ...@@ -67,7 +67,7 @@ func TestStartGrpcServer(t *testing.T) {
client, cleanUp := setUpGrpcEnv() client, cleanUp := setUpGrpcEnv()
defer cleanUp() 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.NoError(t, err)
assert.NotNil(t, resp) assert.NotNil(t, resp)
......
...@@ -46,7 +46,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) { ...@@ -46,7 +46,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) {
mock.SetUpGrpcServer() mock.SetUpGrpcServer()
SetUpHttpGateway() SetUpHttpGateway()
jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) jsonData := []byte(`{"mukId": "testMukId"}`)
resp, err := http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData)) resp, err := http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData))
assert.NoError(t, err) assert.NoError(t, err)
...@@ -102,19 +102,19 @@ func TestErrorHandler(t *testing.T) { ...@@ -102,19 +102,19 @@ func TestErrorHandler(t *testing.T) {
}) })
t.Run("should have conflict error", func(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) assertErroneousRequest(jsonData, http.StatusConflict)
}) })
t.Run("should have unavailable error", func(t *testing.T) { t.Run("should have unavailable error", func(t *testing.T) {
jsonData := []byte(`{"fachstelle": {"mukId": "unavailableMukId"}}`) jsonData := []byte(`{"mukId": "unavailableMukId"}`)
assertErroneousRequest(jsonData, http.StatusServiceUnavailable) assertErroneousRequest(jsonData, http.StatusServiceUnavailable)
}) })
t.Run("should have internal server error", func(t *testing.T) { t.Run("should have internal server error", func(t *testing.T) {
jsonData := []byte(`{"fachstelle": {"mukId": "erroneousMukId"}}`) jsonData := []byte(`{"mukId": "erroneousMukId"}`)
assertErroneousRequest(jsonData, http.StatusInternalServerError) assertErroneousRequest(jsonData, http.StatusInternalServerError)
}) })
......
...@@ -47,12 +47,12 @@ func TestRequestLoggingMiddleware(t *testing.T) { ...@@ -47,12 +47,12 @@ func TestRequestLoggingMiddleware(t *testing.T) {
logger.BaseLogger.SetFlags(originalFlags) 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)) http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData))
logOutput := buf.String() logOutput := buf.String()
assert.Contains(t, logOutput, "received 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: {\"fachstelle\": {\"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) { t.Run("should not log request", func(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment