diff --git a/internal/server/grpc_router.go b/internal/server/grpc_router.go index a0437cd9c32040fdeed1005bd534d2578e88c7e8..2d8609a173bb4513936ce6526c1893f30bc4205f 100644 --- a/internal/server/grpc_router.go +++ b/internal/server/grpc_router.go @@ -63,9 +63,9 @@ func (s *collaborationRouter) FindVorgang(ctx context.Context, in *pb.GrpcFindVo } defer connCleanUp() - updatedRequest := &pb.GrpcFindVorgangRequest{VorgangId: collaborationInfo.Attribute, SamlToken: in.SamlToken} + in.VorgangId = collaborationInfo.Attribute - return client.FindVorgang(context.Background(), updatedRequest) + return client.FindVorgang(context.Background(), in) } type CollaborationInfo struct { diff --git a/internal/server/handler_test.go b/internal/server/handler_test.go index 47b2250b3a15235aba5052ae6b321c42e63882c3..88ae7279dae028028ce7fd2b8cb5e4ab1e045211 100644 --- a/internal/server/handler_test.go +++ b/internal/server/handler_test.go @@ -28,7 +28,6 @@ package server import ( "bytes" "fachstellen-proxy/internal/mock" - "fmt" "github.com/stretchr/testify/assert" "net/http" "testing" @@ -48,7 +47,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) { SetUpHttpGateway() jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) - resp, err := http.Post(fmt.Sprintf("http://localhost:8080%v", FachstelleRegistrationUrlPath), "application/json", bytes.NewBuffer(jsonData)) + resp, err := http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData)) assert.NoError(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) @@ -59,7 +58,7 @@ func TestRegisterCollaborationEndpoints(t *testing.T) { SetUpHttpGateway() SetUpCollaborationRouter() - resp, err := http.Get(fmt.Sprintf("http://localhost:8080%v/bG9jYWxob3N0L3Rlc3RWb3JnYW5nSWQ=/testSamlToken", VorgangUrlBasePath)) + resp, err := http.Get("http://localhost:8080/api/vorgang/bG9jYWxob3N0L3Rlc3RWb3JnYW5nSWQ=/testSamlToken") assert.NoError(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) @@ -70,7 +69,7 @@ func TestErrorHandler(t *testing.T) { mock.SetUpGrpcServer() SetUpHttpGateway() - resp, err := http.Post(fmt.Sprintf("http://localhost:8080%v", FachstelleRegistrationUrlPath), "application/json", bytes.NewBuffer(jsonData)) + resp, err := http.Post("http://localhost:8080/api/fachstellen", "application/json", bytes.NewBuffer(jsonData)) assert.NoError(t, err) assert.Equal(t, expectedStatusCode, resp.StatusCode) diff --git a/internal/server/middleware.go b/internal/server/middleware.go index fc33db1c58ac745b04931d64f46e4f1591010a10..41710750de6006fed161507fd8ba65846ef1601b 100644 --- a/internal/server/middleware.go +++ b/internal/server/middleware.go @@ -30,13 +30,9 @@ import ( "fmt" "io" "net/http" - "strings" ) -const ( - FachstelleRegistrationUrlPath = "/api/fachstellen" - VorgangUrlBasePath = "/api/vorgang" -) +const HomeUrlPath = "/" type logResponseWriter struct { http.ResponseWriter @@ -50,7 +46,7 @@ func (rsp *logResponseWriter) WriteHeader(statusCode int) { func RequestLoggingMiddleware(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !isRequestToBeLogged(r.URL.Path) { + if r.URL.Path == HomeUrlPath { h.ServeHTTP(w, r) return } @@ -75,15 +71,3 @@ func RequestLoggingMiddleware(h http.Handler) http.Handler { } }) } - -func isRequestToBeLogged(path string) bool { - requestPathsToBeLogged := []string{FachstelleRegistrationUrlPath, VorgangUrlBasePath} - - for _, rp := range requestPathsToBeLogged { - if strings.Contains(path, rp) { - return true - } - } - - return false -} diff --git a/internal/server/middleware_test.go b/internal/server/middleware_test.go index 798a7b3a6052ac760334c91efffbe68bd771533e..90806e9ca0b4077e8383c3f1cb089f7fdfd0f70e 100644 --- a/internal/server/middleware_test.go +++ b/internal/server/middleware_test.go @@ -28,7 +28,6 @@ package server import ( "bytes" "fachstellen-proxy/internal/mock" - "fmt" "github.com/stretchr/testify/assert" "net/http" "testing" @@ -49,7 +48,7 @@ func TestRequestLoggingMiddleware(t *testing.T) { }() jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) - http.Post(fmt.Sprintf("http://localhost:8080%v", FachstelleRegistrationUrlPath), "application/json", bytes.NewBuffer(jsonData)) + 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\"}}")