mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 18:07:17 +02:00
authenticate: apply branding to sign out pages (#5044)
Add support for the Enterprise branding options to the sign_out and signed_out page handlers.
This commit is contained in:
parent
40655e491a
commit
e8edb465f4
4 changed files with 67 additions and 6 deletions
|
@ -16,9 +16,11 @@ import (
|
|||
"github.com/golang/mock/gomock"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/crypto/chacha20poly1305"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/internal/atomicutil"
|
||||
|
@ -33,6 +35,7 @@ import (
|
|||
"github.com/pomerium/pomerium/internal/testutil"
|
||||
"github.com/pomerium/pomerium/internal/urlutil"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
configproto "github.com/pomerium/pomerium/pkg/grpc/config"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
)
|
||||
|
||||
|
@ -619,6 +622,49 @@ func TestAuthenticate_CORS(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestSignOutBranding(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
auth := testAuthenticate()
|
||||
auth.state.Load().flow.(*stubFlow).verifySignatureErr = errors.New("unsigned URL")
|
||||
auth.options.Store(&config.Options{
|
||||
BrandingOptions: &configproto.Settings{
|
||||
PrimaryColor: proto.String("red"),
|
||||
SecondaryColor: proto.String("orange"),
|
||||
},
|
||||
})
|
||||
|
||||
t.Run("sign_out", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodGet, "/.pomerium/sign_out", nil)
|
||||
err := auth.SignOut(w, r)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
b, err := io.ReadAll(w.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Contains(t, string(b), `"primaryColor":"red","secondaryColor":"orange"`)
|
||||
})
|
||||
|
||||
t.Run("signed_out", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodGet, "/.pomerium/signed_out", nil)
|
||||
err := auth.signedOut(w, r)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
b, err := io.ReadAll(w.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Contains(t, string(b), `"primaryColor":"red","secondaryColor":"orange"`)
|
||||
})
|
||||
}
|
||||
|
||||
type mockDataBrokerServiceClient struct {
|
||||
databroker.DataBrokerServiceClient
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue