Skip to content
Snippets Groups Projects
Commit 3ca946c7 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6514 Refactoring

parent b53fab23
No related branches found
No related tags found
No related merge requests found
...@@ -63,9 +63,9 @@ func (s *collaborationRouter) FindVorgang(ctx context.Context, in *pb.GrpcFindVo ...@@ -63,9 +63,9 @@ func (s *collaborationRouter) FindVorgang(ctx context.Context, in *pb.GrpcFindVo
} }
defer connCleanUp() 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 { type CollaborationInfo struct {
......
...@@ -28,7 +28,6 @@ package server ...@@ -28,7 +28,6 @@ package server
import ( import (
"bytes" "bytes"
"fachstellen-proxy/internal/mock" "fachstellen-proxy/internal/mock"
"fmt"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"net/http" "net/http"
"testing" "testing"
...@@ -48,7 +47,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) { ...@@ -48,7 +47,7 @@ func TestRegisterFachstelleRegistrationEndpoints(t *testing.T) {
SetUpHttpGateway() SetUpHttpGateway()
jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) 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.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
...@@ -59,7 +58,7 @@ func TestRegisterCollaborationEndpoints(t *testing.T) { ...@@ -59,7 +58,7 @@ func TestRegisterCollaborationEndpoints(t *testing.T) {
SetUpHttpGateway() SetUpHttpGateway()
SetUpCollaborationRouter() 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.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
...@@ -70,7 +69,7 @@ func TestErrorHandler(t *testing.T) { ...@@ -70,7 +69,7 @@ func TestErrorHandler(t *testing.T) {
mock.SetUpGrpcServer() mock.SetUpGrpcServer()
SetUpHttpGateway() 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.NoError(t, err)
assert.Equal(t, expectedStatusCode, resp.StatusCode) assert.Equal(t, expectedStatusCode, resp.StatusCode)
......
...@@ -30,13 +30,9 @@ import ( ...@@ -30,13 +30,9 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"strings"
) )
const ( const HomeUrlPath = "/"
FachstelleRegistrationUrlPath = "/api/fachstellen"
VorgangUrlBasePath = "/api/vorgang"
)
type logResponseWriter struct { type logResponseWriter struct {
http.ResponseWriter http.ResponseWriter
...@@ -50,7 +46,7 @@ func (rsp *logResponseWriter) WriteHeader(statusCode int) { ...@@ -50,7 +46,7 @@ func (rsp *logResponseWriter) WriteHeader(statusCode int) {
func RequestLoggingMiddleware(h http.Handler) http.Handler { func RequestLoggingMiddleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !isRequestToBeLogged(r.URL.Path) { if r.URL.Path == HomeUrlPath {
h.ServeHTTP(w, r) h.ServeHTTP(w, r)
return return
} }
...@@ -75,15 +71,3 @@ func RequestLoggingMiddleware(h http.Handler) http.Handler { ...@@ -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
}
...@@ -28,7 +28,6 @@ package server ...@@ -28,7 +28,6 @@ package server
import ( import (
"bytes" "bytes"
"fachstellen-proxy/internal/mock" "fachstellen-proxy/internal/mock"
"fmt"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"net/http" "net/http"
"testing" "testing"
...@@ -49,7 +48,7 @@ func TestRequestLoggingMiddleware(t *testing.T) { ...@@ -49,7 +48,7 @@ func TestRequestLoggingMiddleware(t *testing.T) {
}() }()
jsonData := []byte(`{"fachstelle": {"mukId": "testMukId"}}`) 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() 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: {\"fachstelle\": {\"mukId\": \"testMukId\"}}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment