mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
proxy: add logo discovery (#5448)
* proxy: add logo discovery * use a static url for testing
This commit is contained in:
parent
936bd28ae4
commit
3c5c7fbd31
4 changed files with 295 additions and 4 deletions
37
proxy/portal/logo_provider_test.go
Normal file
37
proxy/portal/logo_provider_test.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package portal_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/testutil"
|
||||
"github.com/pomerium/pomerium/proxy/portal"
|
||||
)
|
||||
|
||||
func TestLogoProvider(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/icon":
|
||||
w.Header().Set("Content-Type", "image/vnd.microsoft.icon")
|
||||
io.WriteString(w, "NOT ACTUALLY AN ICON")
|
||||
case "/":
|
||||
io.WriteString(w, `<!doctype html><html><head><link rel="icon" href="/icon" /></head><body></body></html>`)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
|
||||
ctx := testutil.GetContext(t, time.Minute)
|
||||
p := portal.NewLogoProvider()
|
||||
u, err := p.GetLogoURL(ctx, "", srv.URL)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "data:image/vnd.microsoft.icon;base64,Tk9UIEFDVFVBTExZIEFOIElDT04=", u)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue