mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 10:56:28 +02:00
* remove source, remove deadcode, fix linting issues * use github action for lint * fix missing envoy
29 lines
826 B
Go
29 lines
826 B
Go
package header
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTokenFromHeader(t *testing.T) {
|
|
t.Run("pomerium header", func(t *testing.T) {
|
|
r, _ := http.NewRequest(http.MethodGet, "http://localhost/some/url", nil)
|
|
r.Header.Set("X-Pomerium-Authorization", "JWT")
|
|
v := TokenFromHeaders(r)
|
|
assert.Equal(t, "JWT", v)
|
|
})
|
|
t.Run("pomerium type", func(t *testing.T) {
|
|
r, _ := http.NewRequest(http.MethodGet, "http://localhost/some/url", nil)
|
|
r.Header.Set("Authorization", "Pomerium JWT")
|
|
v := TokenFromHeaders(r)
|
|
assert.Equal(t, "JWT", v)
|
|
})
|
|
t.Run("bearer type", func(t *testing.T) {
|
|
r, _ := http.NewRequest(http.MethodGet, "http://localhost/some/url", nil)
|
|
r.Header.Set("Authorization", "Bearer Pomerium-JWT")
|
|
v := TokenFromHeaders(r)
|
|
assert.Equal(t, "JWT", v)
|
|
})
|
|
}
|