mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-09 23:27:43 +02:00
Improve test coverage. (#8)
* Improve test coverage. * Remove unused http status code argument from SignInPageMethod. * Removed log package in internal packages. * Add test to check https scheme is used for authorization url. * Add unit tests for global logging package.
This commit is contained in:
parent
5a75ace403
commit
56c89e8653
14 changed files with 478 additions and 105 deletions
|
@ -92,14 +92,12 @@ func (o *Options) Validate() error {
|
|||
if o.SharedKey == "" {
|
||||
return errors.New("missing setting: shared secret")
|
||||
}
|
||||
|
||||
decodedCookieSecret, err := base64.StdEncoding.DecodeString(o.CookieSecret)
|
||||
if err != nil {
|
||||
return fmt.Errorf("authenticate options: cookie secret invalid"+
|
||||
"must be a base64-encoded, 256 bit key e.g. `head -c32 /dev/urandom | base64`"+
|
||||
"got %q", err)
|
||||
}
|
||||
|
||||
validCookieSecretLength := false
|
||||
for _, i := range []int{32, 64} {
|
||||
if len(decodedCookieSecret) == i {
|
||||
|
@ -108,11 +106,8 @@ func (o *Options) Validate() error {
|
|||
}
|
||||
|
||||
if !validCookieSecretLength {
|
||||
return fmt.Errorf("authenticate options: invalid cookie secret strength want 32 to 64 bytes, got %d bytes", len(decodedCookieSecret))
|
||||
}
|
||||
|
||||
if o.CookieRefresh >= o.CookieExpire {
|
||||
return fmt.Errorf("cookie_refresh (%s) must be less than cookie_expire (%s)", o.CookieRefresh.String(), o.CookieExpire.String())
|
||||
return fmt.Errorf("authenticate options: invalid cookie secret strength want"+
|
||||
" 32 to 64 bytes, got %d bytes", len(decodedCookieSecret))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue