mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 09:56:31 +02:00
* update config file paths hash * update filemgr * use xxh3 for hashutil.Hash * update hashutil digest, fix trace buffer test * update comments * update namegen, go mod tidy
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package proxy
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/pomerium/pomerium/config"
|
|
"github.com/pomerium/pomerium/internal/httputil"
|
|
)
|
|
|
|
func TestProxy_routesPortalJSON(t *testing.T) {
|
|
ctx := context.Background()
|
|
cfg := &config.Config{Options: config.NewDefaultOptions()}
|
|
to, err := config.ParseWeightedUrls("https://to.example.com")
|
|
require.NoError(t, err)
|
|
cfg.Options.Routes = append(cfg.Options.Routes, config.Policy{
|
|
Name: "public",
|
|
Description: "PUBLIC ROUTE",
|
|
LogoURL: "https://logo.example.com",
|
|
From: "https://from.example.com",
|
|
To: to,
|
|
AllowPublicUnauthenticatedAccess: true,
|
|
})
|
|
proxy, err := New(ctx, cfg)
|
|
require.NoError(t, err)
|
|
|
|
r := httptest.NewRequest(http.MethodGet, "/.pomerium/api/v1/routes", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
router := httputil.NewRouter()
|
|
router = proxy.registerDashboardHandlers(router, cfg.Options)
|
|
router.ServeHTTP(w, r)
|
|
|
|
assert.Equal(t, http.StatusOK, w.Code)
|
|
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))
|
|
assert.JSONEq(t, `{"routes":[
|
|
{
|
|
"id": "1013c6be524d7fbd",
|
|
"name": "public",
|
|
"from": "https://from.example.com",
|
|
"type": "http",
|
|
"description": "PUBLIC ROUTE",
|
|
"logo_url": "https://logo.example.com"
|
|
}
|
|
]}`, w.Body.String())
|
|
}
|