mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +02:00
Fetch the HPKE public key only when configured to use the hosted authenticate service. Determine whether we are using the hosted authenticate service by comparing the resolved authenticate domain with a hard-coded list of hosted authenticate domains. Extract this list of hosted authenticate domains to the internal/urlutil package in order to keep a single source of truth for this data.
26 lines
517 B
Go
26 lines
517 B
Go
package hpke_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/pomerium/pomerium/pkg/hpke"
|
|
)
|
|
|
|
func TestStubFetcher(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
hpkePrivateKey, err := hpke.GeneratePrivateKey()
|
|
require.NoError(t, err)
|
|
|
|
expected := hpkePrivateKey.PublicKey()
|
|
|
|
f := hpke.NewStubKeyFetcher(expected)
|
|
|
|
actual, err := f.FetchPublicKey(context.Background())
|
|
require.NoError(t, err)
|
|
assert.Equal(t, expected.String(), actual.String())
|
|
}
|