middleware

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 19 Imported by: 13

Documentation

Overview

Package mock_middleware is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authentication

func Authentication() martini.Handler

Authentication authenticates user using keystone

func Authorization

func Authorization(action string) martini.Handler

Authorization checks user permissions against policy

func FakeKeystone

func FakeKeystone(martini *martini.ClassicMartini)

FakeKeystone server for only test purpose

func HTTPJSONError

func HTTPJSONError(res http.ResponseWriter, err string, code int)

HTTPJSONError helper for returning JSON errors

func JSONURLs

func JSONURLs() martini.Handler

JSONURLs strips ".json" suffixes added to URLs

func Logging

func Logging() martini.Handler

Logging logs requests and responses

func Metrics

func Metrics() martini.Handler

func ReadJSON

func ReadJSON(r *http.Request) (map[string]interface{}, error)

ReadJSON reads JSON from http request

func WithContext

func WithContext() martini.Handler

WithContext injects new empty context object

Types

type CachedIdentityService

type CachedIdentityService struct {
	// contains filtered or unexported fields
}

func (*CachedIdentityService) GetClient

func (*CachedIdentityService) GetServiceAuthorization

func (c *CachedIdentityService) GetServiceAuthorization() (schema.Authorization, error)

func (*CachedIdentityService) GetTenantID

func (c *CachedIdentityService) GetTenantID(tenantName string) (string, error)

func (*CachedIdentityService) GetTenantName

func (c *CachedIdentityService) GetTenantName(tenantID string) (string, error)

func (*CachedIdentityService) VerifyToken

func (c *CachedIdentityService) VerifyToken(token string) (schema.Authorization, error)

type Context

type Context map[string]interface{}

Context type

type DefaultNobodyResourceService

type DefaultNobodyResourceService struct {
	// contains filtered or unexported fields
}

DefaultNobodyResourceService contains a definition of default nobody resources

func (*DefaultNobodyResourceService) VerifyResourcePath

func (nrs *DefaultNobodyResourceService) VerifyResourcePath(resourcePath string) bool

VerifyResourcePath verifies resource path

type FakeIdentity

type FakeIdentity struct{}

FakeIdentity middleware

func (*FakeIdentity) GetClient

func (identity *FakeIdentity) GetClient() *gophercloud.ServiceClient

GetClient returns openstack client

func (*FakeIdentity) GetServiceAuthorization

func (identity *FakeIdentity) GetServiceAuthorization() (schema.Authorization, error)

GetServiceAuthorization returns the master authorization with full permission

func (*FakeIdentity) GetTenantID

func (*FakeIdentity) GetTenantID(tenantName string) (string, error)

GetTenantID maps the given tenant name to the tenant's ID

func (*FakeIdentity) GetTenantName

func (*FakeIdentity) GetTenantName(tenantID string) (string, error)

GetTenantName maps the given tenant ID to the tenant's name

func (*FakeIdentity) VerifyToken

func (*FakeIdentity) VerifyToken(tokenID string) (schema.Authorization, error)

VerifyToken fake verify

type IdentityService

type IdentityService interface {
	GetTenantID(string) (string, error)
	GetTenantName(string) (string, error)
	VerifyToken(string) (schema.Authorization, error)
	GetServiceAuthorization() (schema.Authorization, error)
	GetClient() *gophercloud.ServiceClient
}

IdentityService for user authentication & authorization

func CreateIdentityServiceFromConfig

func CreateIdentityServiceFromConfig(config *util.Config) (IdentityService, error)

CreateIdentityServiceFromConfig creates keystone identity from config

func NewCachedIdentityService

func NewCachedIdentityService(inner IdentityService, ttl time.Duration) IdentityService

type MockIdentityService

type MockIdentityService struct {
	// contains filtered or unexported fields
}

MockIdentityService is a mock of IdentityService interface

func NewMockIdentityService

func NewMockIdentityService(ctrl *gomock.Controller) *MockIdentityService

NewMockIdentityService creates a new mock instance

func (*MockIdentityService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockIdentityService) GetClient

GetClient mocks base method

func (*MockIdentityService) GetServiceAuthorization

func (m *MockIdentityService) GetServiceAuthorization() (schema.Authorization, error)

GetServiceAuthorization mocks base method

func (*MockIdentityService) GetTenantID

func (m *MockIdentityService) GetTenantID(arg0 string) (string, error)

GetTenantID mocks base method

func (*MockIdentityService) GetTenantName

func (m *MockIdentityService) GetTenantName(arg0 string) (string, error)

GetTenantName mocks base method

func (*MockIdentityService) VerifyToken

func (m *MockIdentityService) VerifyToken(arg0 string) (schema.Authorization, error)

VerifyToken mocks base method

type MockIdentityServiceMockRecorder

type MockIdentityServiceMockRecorder struct {
	// contains filtered or unexported fields
}

MockIdentityServiceMockRecorder is the mock recorder for MockIdentityService

func (*MockIdentityServiceMockRecorder) GetClient

func (mr *MockIdentityServiceMockRecorder) GetClient() *gomock.Call

GetClient indicates an expected call of GetClient

func (*MockIdentityServiceMockRecorder) GetServiceAuthorization

func (mr *MockIdentityServiceMockRecorder) GetServiceAuthorization() *gomock.Call

GetServiceAuthorization indicates an expected call of GetServiceAuthorization

func (*MockIdentityServiceMockRecorder) GetTenantID

func (mr *MockIdentityServiceMockRecorder) GetTenantID(arg0 interface{}) *gomock.Call

GetTenantID indicates an expected call of GetTenantID

func (*MockIdentityServiceMockRecorder) GetTenantName

func (mr *MockIdentityServiceMockRecorder) GetTenantName(arg0 interface{}) *gomock.Call

GetTenantName indicates an expected call of GetTenantName

func (*MockIdentityServiceMockRecorder) VerifyToken

func (mr *MockIdentityServiceMockRecorder) VerifyToken(arg0 interface{}) *gomock.Call

VerifyToken indicates an expected call of VerifyToken

type MockNobodyResourceService

type MockNobodyResourceService struct {
	// contains filtered or unexported fields
}

MockNobodyResourceService is a mock of NobodyResourceService interface

func NewMockNobodyResourceService

func NewMockNobodyResourceService(ctrl *gomock.Controller) *MockNobodyResourceService

NewMockNobodyResourceService creates a new mock instance

func (*MockNobodyResourceService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockNobodyResourceService) VerifyResourcePath

func (m *MockNobodyResourceService) VerifyResourcePath(arg0 string) bool

VerifyResourcePath mocks base method

type MockNobodyResourceServiceMockRecorder

type MockNobodyResourceServiceMockRecorder struct {
	// contains filtered or unexported fields
}

MockNobodyResourceServiceMockRecorder is the mock recorder for MockNobodyResourceService

func (*MockNobodyResourceServiceMockRecorder) VerifyResourcePath

func (mr *MockNobodyResourceServiceMockRecorder) VerifyResourcePath(arg0 interface{}) *gomock.Call

VerifyResourcePath indicates an expected call of VerifyResourcePath

type NoIdentityService

type NoIdentityService struct {
}

NoIdentityService for disabled auth

func (*NoIdentityService) GetClient

GetClient returns always nil

func (*NoIdentityService) GetServiceAuthorization

func (i *NoIdentityService) GetServiceAuthorization() (schema.Authorization, error)

GetServiceAuthorization returns always authorization for admin

func (*NoIdentityService) GetTenantID

func (i *NoIdentityService) GetTenantID(string) (string, error)

GetTenantID returns always admin

func (*NoIdentityService) GetTenantName

func (i *NoIdentityService) GetTenantName(string) (string, error)

GetTenantName returns always admin

func (*NoIdentityService) VerifyToken

func (i *NoIdentityService) VerifyToken(string) (schema.Authorization, error)

VerifyToken returns always authorization for admin

type NobodyIdentityService

type NobodyIdentityService struct {
}

NobodyIdentityService for nobody auth

func (*NobodyIdentityService) GetClient

GetClient returns always nil

func (*NobodyIdentityService) GetServiceAuthorization

func (i *NobodyIdentityService) GetServiceAuthorization() (schema.Authorization, error)

GetServiceAuthorization returns always authorization for nobody

func (*NobodyIdentityService) GetTenantID

func (i *NobodyIdentityService) GetTenantID(string) (string, error)

GetTenantID returns always nobody

func (*NobodyIdentityService) GetTenantName

func (i *NobodyIdentityService) GetTenantName(string) (string, error)

GetTenantName returns always nobody

func (*NobodyIdentityService) VerifyToken

VerifyToken returns always authorization for nobody

type NobodyResourceService

type NobodyResourceService interface {
	VerifyResourcePath(string) bool
}

NobodyResourceService contains a definition of nobody resources (that do not require authorization)

func NewNobodyResourceService

func NewNobodyResourceService(nobodyResourcePathRegexes []*regexp.Regexp) NobodyResourceService

NewNobodyResourceService is a constructor for NobodyResourceService

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL