mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-23 05:57:19 +02:00
proxy: add unit tests (#43)
This commit is contained in:
parent
cedf9922d3
commit
4f4f3965aa
12 changed files with 577 additions and 323 deletions
35
proxy/authenticator/mock_authenticator.go
Normal file
35
proxy/authenticator/mock_authenticator.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package authenticator // import "github.com/pomerium/pomerium/proxy/authenticator"
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// MockAuthenticate is a mock authenticator interface
|
||||
type MockAuthenticate struct {
|
||||
RedeemError error
|
||||
RedeemResponse *RedeemResponse
|
||||
RefreshResponse string
|
||||
RefreshTime time.Time
|
||||
RefreshError error
|
||||
ValidateResponse bool
|
||||
ValidateError error
|
||||
CloseError error
|
||||
}
|
||||
|
||||
// Redeem is a mocked implementation for authenticator testing.
|
||||
func (a MockAuthenticate) Redeem(code string) (*RedeemResponse, error) {
|
||||
return a.RedeemResponse, a.RedeemError
|
||||
}
|
||||
|
||||
// Refresh is a mocked implementation for authenticator testing.
|
||||
func (a MockAuthenticate) Refresh(refreshToken string) (string, time.Time, error) {
|
||||
return a.RefreshResponse, a.RefreshTime, a.RefreshError
|
||||
}
|
||||
|
||||
// Validate is a mocked implementation for authenticator testing.
|
||||
func (a MockAuthenticate) Validate(idToken string) (bool, error) {
|
||||
return a.ValidateResponse, a.ValidateError
|
||||
}
|
||||
|
||||
// Close is a mocked implementation for authenticator testing.
|
||||
func (a MockAuthenticate) Close() error { return a.ValidateError }
|
Loading…
Add table
Add a link
Reference in a new issue