pomerium/pkg/hpke/stub_test.go
Kenneth Jenkins a1388592d8
stub out HPKE public key fetch for self-hosted authenticate (#4360)
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.
2023-07-13 10:04:34 -07:00

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())
}