mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-09 23:27:43 +02:00
authenticate: protect /.pomerium/admin endpoint (#1500)
* authenticate: protect /.pomerium/admin endpoint * add integration test
This commit is contained in:
parent
dc1c83c4de
commit
27d0cf180a
4 changed files with 131 additions and 78 deletions
|
@ -8,6 +8,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pomerium/pomerium/integration/internal/flows"
|
||||
)
|
||||
|
||||
func TestDashboard(t *testing.T) {
|
||||
|
@ -15,6 +17,28 @@ func TestDashboard(t *testing.T) {
|
|||
ctx, clearTimeout := context.WithTimeout(ctx, time.Second*30)
|
||||
defer clearTimeout()
|
||||
|
||||
t.Run("admin impersonate", func(t *testing.T) {
|
||||
client := testcluster.NewHTTPClient()
|
||||
|
||||
res, err := flows.Authenticate(ctx, client, mustParseURL("https://httpdetails.localhost.pomerium.io/by-user"),
|
||||
flows.WithEmail("bob@dogs.test"), flows.WithGroups("user"))
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://httpdetails.localhost.pomerium.io/.pomerium/admin/impersonate", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err = client.Do(req)
|
||||
if !assert.NoError(t, err, "unexpected http error") {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
assertDeniedAccess(t, res)
|
||||
})
|
||||
t.Run("user dashboard", func(t *testing.T) {
|
||||
client := testcluster.NewHTTPClient()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue