mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 23:57:34 +02:00
authenticate: catch missing required setting (#149)
This commit is contained in:
parent
191015a0ed
commit
7487de94df
2 changed files with 4 additions and 1 deletions
|
@ -19,7 +19,7 @@ import (
|
||||||
// The checks do not modify the internal state of the Option structure. Returns
|
// The checks do not modify the internal state of the Option structure. Returns
|
||||||
// on first error found.
|
// on first error found.
|
||||||
func ValidateOptions(o *config.Options) error {
|
func ValidateOptions(o *config.Options) error {
|
||||||
if o.AuthenticateURL == nil {
|
if o.AuthenticateURL == nil || o.AuthenticateURL.Hostname() == "" {
|
||||||
return errors.New("authenticate: 'AUTHENTICATE_SERVICE_URL' missing")
|
return errors.New("authenticate: 'AUTHENTICATE_SERVICE_URL' missing")
|
||||||
}
|
}
|
||||||
if o.ClientID == "" {
|
if o.ClientID == "" {
|
||||||
|
|
|
@ -38,6 +38,8 @@ func TestOptions_Validate(t *testing.T) {
|
||||||
shortCookieLength.CookieSecret = "gN3xnvfsAwfCXxnJorGLKUG4l2wC8sS8nfLMhcStPg=="
|
shortCookieLength.CookieSecret = "gN3xnvfsAwfCXxnJorGLKUG4l2wC8sS8nfLMhcStPg=="
|
||||||
badSharedKey := testOptions()
|
badSharedKey := testOptions()
|
||||||
badSharedKey.SharedKey = ""
|
badSharedKey.SharedKey = ""
|
||||||
|
badAuthenticateURL := testOptions()
|
||||||
|
badAuthenticateURL.AuthenticateURL = new(url.URL)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -53,6 +55,7 @@ func TestOptions_Validate(t *testing.T) {
|
||||||
{"no shared secret", badSharedKey, true},
|
{"no shared secret", badSharedKey, true},
|
||||||
{"no client id", emptyClientID, true},
|
{"no client id", emptyClientID, true},
|
||||||
{"no client secret", emptyClientSecret, true},
|
{"no client secret", emptyClientSecret, true},
|
||||||
|
{"empty authenticate url", badAuthenticateURL, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue