mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 01:47:33 +02:00
integration: add single-cluster integration tests (#2516)
* integration: add single-cluster integration tests * remove kind load
This commit is contained in:
parent
f5a558d4a0
commit
48cd10d46b
53 changed files with 7455 additions and 31 deletions
103
integration/control_plane_test.go
Normal file
103
integration/control_plane_test.go
Normal file
|
@ -0,0 +1,103 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDashboard(t *testing.T) {
|
||||
ctx, clearTimeout := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer clearTimeout()
|
||||
|
||||
t.Run("user dashboard", func(t *testing.T) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://authenticate.localhost.pomerium.io/.pomerium/", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := getClient().Do(req)
|
||||
if !assert.NoError(t, err, "unexpected http error") {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
|
||||
assert.Equal(t, http.StatusFound, res.StatusCode, "unexpected status code: %s", body)
|
||||
})
|
||||
t.Run("dashboard strict slash redirect", func(t *testing.T) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://authenticate.localhost.pomerium.io/.pomerium", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := getClient().Do(req)
|
||||
if !assert.NoError(t, err, "unexpected http error") {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
assert.Equal(t, 3, res.StatusCode/100, "unexpected status code")
|
||||
})
|
||||
t.Run("image asset", func(t *testing.T) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://authenticate.localhost.pomerium.io/.pomerium/assets/img/pomerium.svg", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := getClient().Do(req)
|
||||
if !assert.NoError(t, err, "unexpected http error") {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
assert.Equal(t, http.StatusOK, res.StatusCode, "unexpected status code")
|
||||
assert.Equal(t, "image/svg+xml", res.Header.Get("Content-Type"))
|
||||
})
|
||||
}
|
||||
|
||||
func TestHealth(t *testing.T) {
|
||||
if ClusterType == "traefik" || ClusterType == "nginx" {
|
||||
t.Skip()
|
||||
return
|
||||
}
|
||||
|
||||
ctx, clearTimeout := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer clearTimeout()
|
||||
|
||||
pomeriumRoutes := []string{
|
||||
"https://authenticate.localhost.pomerium.io",
|
||||
"https://httpdetails.localhost.pomerium.io",
|
||||
"https://restricted-httpdetails.localhost.pomerium.io",
|
||||
"https://unknown.localhost.pomerium.io",
|
||||
}
|
||||
endpoints := []string{"healthz", "ping"}
|
||||
|
||||
for _, route := range pomeriumRoutes {
|
||||
route := route
|
||||
for _, endpoint := range endpoints {
|
||||
endpoint := endpoint
|
||||
routeToCheck := fmt.Sprintf("%s/%s", route, endpoint)
|
||||
t.Run(routeToCheck, func(t *testing.T) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", routeToCheck, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := getClient().Do(req)
|
||||
if !assert.NoError(t, err, "unexpected http error") {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
assert.Equal(t, http.StatusOK, res.StatusCode, "unexpected status code")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue