1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-15 00:15:00 +02:00

Add tests for cookie validation

This also removes the check for the decoded from the valid secret size
check. The code was unreachable because encryption.SecretBytes will only
return the decoded secret if it was the right length after decoding.
This commit is contained in:
Joel Speed
2020-05-25 12:01:16 +01:00
parent 900061b88a
commit 285c65a2d4
3 changed files with 253 additions and 25 deletions

View File

@ -2,7 +2,6 @@ package validation
import (
"crypto"
"fmt"
"io/ioutil"
"net/url"
"os"
@ -291,20 +290,6 @@ func TestValidateSignatureKeyUnsupportedAlgorithm(t *testing.T) {
" unsupported signature hash algorithm: "+o.SignatureKey)
}
func TestValidateCookie(t *testing.T) {
o := testOptions()
o.Cookie.Name = "_valid_cookie_name"
assert.Equal(t, nil, Validate(o))
}
func TestValidateCookieBadName(t *testing.T) {
o := testOptions()
o.Cookie.Name = "_bad_cookie_name{}"
err := Validate(o)
assert.Equal(t, err.Error(), "invalid configuration:\n"+
fmt.Sprintf(" invalid cookie name: %q", o.Cookie.Name))
}
func TestSkipOIDCDiscovery(t *testing.T) {
o := testOptions()
o.ProviderType = "oidc"