Documentation
¶
Index ¶
- Variables
- func ApiKeyAuthFinder(serviceUUID string, host string, store stores.Store) ([]stores.QAuthMethod, error)
- func AuthMethodAlreadyExists(serviceUUID string, host string, authMethodType string, store stores.Store) error
- func AuthMethodConvertToQueryModel(fromAM AuthMethod, toType string) (stores.QAuthMethod, error)
- func AuthMethodCreate(am AuthMethod, store stores.Store, typeOfAuthMethod string) error
- func AuthMethodDelete(am AuthMethod, store stores.Store) error
- func ExternalServiceHandlerIncorrectRetrievalField(w http.ResponseWriter, r *http.Request)
- func ExternalServiceHandlerSuccess(w http.ResponseWriter, r *http.Request)
- func HeadersAuthFinder(serviceUUID string, host string, store stores.Store) ([]stores.QAuthMethod, error)
- func MockKeyAuthFinder(serviceUUID string, host string, store stores.Store) ([]stores.QAuthMethod, error)
- func MockRequestDispatcher(handler ExternalServiceHandler) (*http.Response, error)
- type ApiKeyAuthMethod
- type AuthMethod
- func AuthMethodFinder(serviceUUID string, host string, authMethodType string, store stores.Store) (AuthMethod, error)
- func AuthMethodUpdate(am AuthMethod, r io.ReadCloser, store stores.Store) (AuthMethod, error)
- func NewApiKeyAuthMethod() AuthMethod
- func NewHeadersAuthMethod() AuthMethod
- func NewMockAuthMethod() AuthMethod
- func QueryModelConvertToAuthMethod(fromQam stores.QAuthMethod, toType string) (AuthMethod, error)
- type AuthMethodFactory
- type AuthMethodInit
- type AuthMethodsList
- type BasicAuthMethod
- type ExternalServiceHandler
- type HeadersAuthMethod
- type MockAuthMethod
- func (m *MockAuthMethod) RetrieveAuthResource(binding bindings.Binding, serviceType servicetypes.ServiceType, ...) (map[string]interface{}, error)
- func (m *MockAuthMethod) SetDefaults(tp string) error
- func (m *MockAuthMethod) Update(r io.ReadCloser) (AuthMethod, error)
- func (m *MockAuthMethod) Validate(store stores.Store) error
- type QMockAuthMethod
- type QueryAuthMethodFinder
- type TempApiKeyAuthMethod
- type TempBasicAuthMethod
- type TempHeadersAuthMethod
Constants ¶
This section is empty.
Variables ¶
var AuthMethodsTypes = map[string]AuthMethodInit{ "api-key": NewApiKeyAuthMethod, "headers": NewHeadersAuthMethod, }
var ExternalServiceHandlers = map[string]ExternalServiceHandler{ "success": ExternalServiceHandlerSuccess, "incorrect-retrieval-field": ExternalServiceHandlerIncorrectRetrievalField, }
ExternalServiceHandlers contains mock handlers that represent various possible scenarios when executing requests to external services
var QueryAuthMethodFinders = map[string]QueryAuthMethodFinder{ "api-key": ApiKeyAuthFinder, "headers": HeadersAuthFinder, }
Functions ¶
func ApiKeyAuthFinder ¶
func AuthMethodAlreadyExists ¶
func AuthMethodAlreadyExists(serviceUUID string, host string, authMethodType string, store stores.Store) error
AuthMethodAlreadyExists checks where or not any type of auth method already exists for the given host and service type
func AuthMethodConvertToQueryModel ¶
func AuthMethodConvertToQueryModel(fromAM AuthMethod, toType string) (stores.QAuthMethod, error)
AuthMethodConvertToQueryModel converts an auth method to a query auth method
func AuthMethodCreate ¶
func AuthMethodCreate(am AuthMethod, store stores.Store, typeOfAuthMethod string) error
AuthMethodCreate inserts the given auth method to the datastore after performing some checks and enriching its contents
func AuthMethodDelete ¶
func AuthMethodDelete(am AuthMethod, store stores.Store) error
AuthMethodDelete deletes the given auth method from the data store
func ExternalServiceHandlerIncorrectRetrievalField ¶
func ExternalServiceHandlerIncorrectRetrievalField(w http.ResponseWriter, r *http.Request)
ExternalServiceHandlerIncorrectRetrievalField mocks the behavior of a successful external request that didn't contain the registered retrieval field
func ExternalServiceHandlerSuccess ¶
func ExternalServiceHandlerSuccess(w http.ResponseWriter, r *http.Request)
MockServiceTypeEndpoint mocks the behavior of a service type endpoint and returns a response containing the requested resource
func HeadersAuthFinder ¶
func MockKeyAuthFinder ¶
func MockKeyAuthFinder(serviceUUID string, host string, store stores.Store) ([]stores.QAuthMethod, error)
MockKeyAuthFinder returns a MockAuthMethod for testing purposes
func MockRequestDispatcher ¶
func MockRequestDispatcher(handler ExternalServiceHandler) (*http.Response, error)
MockRequestDispatcher executes and captures the response of a mock handler
Types ¶
type ApiKeyAuthMethod ¶
type ApiKeyAuthMethod struct { BasicAuthMethod AccessKey string `json:"access_key" required:"true"` }
func (*ApiKeyAuthMethod) RetrieveAuthResource ¶
func (m *ApiKeyAuthMethod) RetrieveAuthResource(binding bindings.Binding, serviceType servicetypes.ServiceType, cfg *config.Config) (map[string]interface{}, error)
func (*ApiKeyAuthMethod) Update ¶
func (m *ApiKeyAuthMethod) Update(r io.ReadCloser) (AuthMethod, error)
type AuthMethod ¶
type AuthMethod interface { Validate(store stores.Store) error Update(r io.ReadCloser) (AuthMethod, error) RetrieveAuthResource(binding bindings.Binding, serviceType servicetypes.ServiceType, cfg *config.Config) (map[string]interface{}, error) }
func AuthMethodFinder ¶
func AuthMethodFinder(serviceUUID string, host string, authMethodType string, store stores.Store) (AuthMethod, error)
AuthMethodFinder uses the appropriate finder to search for a specific type of auth methods
func AuthMethodUpdate ¶
func AuthMethodUpdate(am AuthMethod, r io.ReadCloser, store stores.Store) (AuthMethod, error)
AuthMethodUpdate updates the given method with a reader's data
func NewApiKeyAuthMethod ¶
func NewApiKeyAuthMethod() AuthMethod
func NewHeadersAuthMethod ¶
func NewHeadersAuthMethod() AuthMethod
func NewMockAuthMethod ¶
func NewMockAuthMethod() AuthMethod
func QueryModelConvertToAuthMethod ¶
func QueryModelConvertToAuthMethod(fromQam stores.QAuthMethod, toType string) (AuthMethod, error)
QueryModelConvertToAuthMethod converts a query auth method to an auth method
type AuthMethodFactory ¶
type AuthMethodFactory struct{}
func NewAuthMethodFactory ¶
func NewAuthMethodFactory() *AuthMethodFactory
func (*AuthMethodFactory) Create ¶
func (f *AuthMethodFactory) Create(amType string) (AuthMethod, error)
type AuthMethodInit ¶
type AuthMethodInit func() AuthMethod
type AuthMethodsList ¶
type AuthMethodsList struct {
AuthMethods []AuthMethod `json:"auth_methods"`
}
func AuthMethodFindAll ¶
func AuthMethodFindAll(store stores.Store) (AuthMethodsList, error)
AuthMethodFindAll finds and returns all the registered auth methods
type BasicAuthMethod ¶
type ExternalServiceHandler ¶
type ExternalServiceHandler func(w http.ResponseWriter, r *http.Request)
type HeadersAuthMethod ¶
type HeadersAuthMethod struct { BasicAuthMethod Headers map[string]string `json:"headers" required:"true"` }
func (*HeadersAuthMethod) RetrieveAuthResource ¶
func (m *HeadersAuthMethod) RetrieveAuthResource(binding bindings.Binding, serviceType servicetypes.ServiceType, cfg *config.Config) (map[string]interface{}, error)
func (*HeadersAuthMethod) Update ¶
func (m *HeadersAuthMethod) Update(r io.ReadCloser) (AuthMethod, error)
type MockAuthMethod ¶
type MockAuthMethod struct {
RetrievalField string `json:"retrieval_field"`
}
func (*MockAuthMethod) RetrieveAuthResource ¶
func (m *MockAuthMethod) RetrieveAuthResource(binding bindings.Binding, serviceType servicetypes.ServiceType, cfg *config.Config) (map[string]interface{}, error)
func (*MockAuthMethod) SetDefaults ¶
func (m *MockAuthMethod) SetDefaults(tp string) error
func (*MockAuthMethod) Update ¶
func (m *MockAuthMethod) Update(r io.ReadCloser) (AuthMethod, error)
type QMockAuthMethod ¶
type QMockAuthMethod struct {
RetrievalField string `json:"retrieval_field"`
}
type QueryAuthMethodFinder ¶
type QueryAuthMethodFinder func(serviceUUID string, host string, store stores.Store) ([]stores.QAuthMethod, error)
A function type that refers to all the query functions for all the respective tuh method types
type TempApiKeyAuthMethod ¶
type TempApiKeyAuthMethod struct { TempBasicAuthMethod AccessKey string `json:"access_key" required:"true"` }
TempApiKeyAuthMethod represents the fields that are allowed to be modified
type TempBasicAuthMethod ¶
type TempBasicAuthMethod struct { ServiceUUID string `json:"service_uuid" required:"true"` Port int `json:"port" required:"true"` Host string `json:"host" required:"true"` }
TempBasicAuthMethod represents the fields that are allowed to be modified
type TempHeadersAuthMethod ¶
type TempHeadersAuthMethod struct { TempBasicAuthMethod Headers map[string]string `json:"headers" required:"true"` }
TempHeadersAuthMethod represents the fields that are allowed to be modified