mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 20:32:57 +02:00
proxy: add route portal json (#5428)
* proxy: add route portal json * fix 405 issue * add link to issue * Update proxy/portal/filter_test.go Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com> --------- Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
This commit is contained in:
parent
6e1fabec0b
commit
e816cef2a1
10 changed files with 628 additions and 5 deletions
51
proxy/handlers_portal_test.go
Normal file
51
proxy/handlers_portal_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
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": "4e71df99c0317efb",
|
||||
"name": "public",
|
||||
"from": "https://from.example.com",
|
||||
"type": "http",
|
||||
"description": "PUBLIC ROUTE",
|
||||
"logo_url": "https://logo.example.com"
|
||||
}
|
||||
]}`, w.Body.String())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue