Documentation ¶
Index ¶
Constants ¶
View Source
const (
Retry = 3
)
Variables ¶
View Source
var ( DummyAccessToken = "dummy-access-token" SendError = "send-error" )
View Source
var ( ErrorCspForbidden = errors.New("forbidden") ErrorCspBadRequest = errors.New("invalid api_token, it might be expired") ErrorRefreshTokenNotValid = errors.New("refresh_token cannot be empty") UnexpectedResponseStatusCode = errors.New("unexpected csp error") )
View Source
var RetryDelay time.Duration = 5
Functions ¶
This section is empty.
Types ¶
type CSPAuthorizeResponse ¶
type CSPAuthorizeResponse struct { RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` AccessToken string `json:"access_token"` Scope string `json:"scope"` IDToken string `json:"id_token"` TokenType string `json:"token_type"` }
CSPAuthorizeResponse represents a response from CSP with information about the authorization. AccessToken is the value needed to perform valid calls to TAC backend.
type CSPClient ¶
type CSPClient interface {
GetCspAuthorization(ctx context.Context, refreshToken string) (*CSPAuthorizeResponse, error)
}
CSPClient represents a CSPClient place here for future mocking purposes Will contain all methods related to calls directly to CSP. Please note this is not usual since it would be TAC the one talking with CSP.
type CSPHttpClient ¶
type CSPHttpClient struct {
// contains filtered or unexported fields
}
CSPHttpClient is the client to perform talks to CSP.
func NewCspHTTPClient ¶
func NewCspHTTPClient() (*CSPHttpClient, error)
NewCspHTTPClient creates a new CSPHttpClient
func (*CSPHttpClient) GetCspAuthorization ¶
func (c *CSPHttpClient) GetCspAuthorization(ctx context.Context, apiToken string) (*CSPAuthorizeResponse, error)
GetCspAuthorization connects to CSP to retrieve information regarding the given API token
type CspAuth ¶
type CspAuth struct { CspClient CSPClient // contains filtered or unexported fields }
type MockCSPClient ¶
type MockCSPClient struct { }
MockCSPClient is a mock of the CSPClient interface
func NewMockCSPClient ¶
func NewMockCSPClient() *MockCSPClient
NewMockCSPClient creates a new mock instance
func (*MockCSPClient) GetCspAuthorization ¶
func (m *MockCSPClient) GetCspAuthorization(ctx context.Context, apiToken string) (*CSPAuthorizeResponse, error)
Click to show internal directories.
Click to hide internal directories.