add missing unprotected flag and fix proxy test

This commit is contained in:
David Christofas
2022-08-30 12:30:12 +02:00
committed by Ralf Haferkamp
parent 69ba80562e
commit 90574268d9
2 changed files with 22 additions and 9 deletions

View File

@@ -99,6 +99,12 @@ func DefaultPolicies() []config.Policy {
Endpoint: "/ocs/v[12].php/cloud/user/signing-key", // only `user/signing-key` is left in ocis-ocs
Backend: "http://localhost:9110",
},
{
Type: config.RegexRoute,
Endpoint: "/ocs/v[12].php/config",
Backend: "http://localhost:9140",
Unprotected: true,
},
{
Endpoint: "/ocs/",
Backend: "http://localhost:9140",
@@ -145,12 +151,14 @@ func DefaultPolicies() []config.Policy {
Service: "com.owncloud.web.ocdav",
},
{
Endpoint: "/status",
Service: "com.owncloud.web.ocdav",
Endpoint: "/status",
Service: "com.owncloud.web.ocdav",
Unprotected: true,
},
{
Endpoint: "/status.php",
Service: "com.owncloud.web.ocdav",
Endpoint: "/status.php",
Service: "com.owncloud.web.ocdav",
Unprotected: true,
},
{
Endpoint: "/index.php/",
@@ -161,8 +169,9 @@ func DefaultPolicies() []config.Policy {
Service: "com.owncloud.web.ocdav",
},
{
Endpoint: "/data",
Backend: "http://localhost:9140",
Endpoint: "/data",
Backend: "http://localhost:9140",
Unprotected: true,
},
{
Endpoint: "/app/", // /app or /apps? ocdav only handles /apps

View File

@@ -2,15 +2,17 @@ package proxy
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/proxy/pkg/config"
"github.com/owncloud/ocis/v2/services/proxy/pkg/router"
)
func TestProxyIntegration(t *testing.T) {
@@ -114,6 +116,8 @@ func TestProxyIntegration(t *testing.T) {
t.Run(tests[k].id, func(t *testing.T) {
t.Parallel()
tc := tests[k]
rt := router.Middleware(nil, tc.conf, log.NewLogger())
rp := newTestProxy(testConfig(tc.conf), func(req *http.Request) *http.Response {
if got, want := req.URL.String(), tc.expect.String(); got != want {
t.Errorf("Proxied url should be %v got %v", want, got)
@@ -135,7 +139,7 @@ func TestProxyIntegration(t *testing.T) {
})
rr := httptest.NewRecorder()
rp.ServeHTTP(rr, tc.input)
rt(rp).ServeHTTP(rr, tc.input)
rsp := rr.Result()
if rsp.StatusCode != 200 {
@@ -204,7 +208,7 @@ func (tc *testCase) withRequest(method string, target string, body io.Reader) *t
func (tc *testCase) expectProxyTo(strURL string) testCase {
pu, err := url.Parse(strURL)
if err != nil {
log.Fatalf("Error parsing %v", strURL)
panic(fmt.Sprintf("Error parsing %v", strURL))
}
tc.expect = pu