mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package identity
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
|
|
"golang.org/x/oauth2"
|
|
|
|
"github.com/pomerium/pomerium/internal/identity/identity"
|
|
)
|
|
|
|
// MockProvider provides a mocked implementation of the providers interface.
|
|
type MockProvider struct {
|
|
AuthenticateResponse oauth2.Token
|
|
AuthenticateError error
|
|
RefreshResponse oauth2.Token
|
|
RefreshError error
|
|
RevokeError error
|
|
GetSignInURLResponse string
|
|
LogOutResponse url.URL
|
|
LogOutError error
|
|
UpdateUserInfoError error
|
|
}
|
|
|
|
// Authenticate is a mocked providers function.
|
|
func (mp MockProvider) Authenticate(context.Context, string, identity.State) (*oauth2.Token, error) {
|
|
return &mp.AuthenticateResponse, mp.AuthenticateError
|
|
}
|
|
|
|
// Refresh is a mocked providers function.
|
|
func (mp MockProvider) Refresh(context.Context, *oauth2.Token, identity.State) (*oauth2.Token, error) {
|
|
return &mp.RefreshResponse, mp.RefreshError
|
|
}
|
|
|
|
// Revoke is a mocked providers function.
|
|
func (mp MockProvider) Revoke(ctx context.Context, s *oauth2.Token) error {
|
|
return mp.RevokeError
|
|
}
|
|
|
|
// GetSignInURL is a mocked providers function.
|
|
func (mp MockProvider) GetSignInURL(s string) string { return mp.GetSignInURLResponse }
|
|
|
|
// LogOut is a mocked providers function.
|
|
func (mp MockProvider) LogOut() (*url.URL, error) { return &mp.LogOutResponse, mp.LogOutError }
|
|
|
|
// UpdateUserInfo is a mocked providers function.
|
|
func (mp MockProvider) UpdateUserInfo(ctx context.Context, t *oauth2.Token, v interface{}) error {
|
|
return mp.UpdateUserInfoError
|
|
}
|
|
|
|
// Name returns the provider name.
|
|
func (mp MockProvider) Name() string {
|
|
return "mock"
|
|
}
|