fake

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	*mock.Mock
}

Service is a fake users.Service implementation.

func NewFakeService

func NewFakeService() *Service

NewFakeService initializes a new fake user service implementation. This provider uses the mock library

func (*Service) AddResourcePermission

func (f *Service) AddResourcePermission(user, resource string, action per.Action) (bool, *gz.ErrMsg)

AddResourcePermission adds a user (or group) permission on a resource

func (*Service) AddScore

func (f *Service) AddScore(groupID *string, competition *string, circuit *string, owner *string, score *float64,
	sources *string) *gz.ErrMsg

AddScore creates a score entry for a simulation.

func (*Service) CanPerformWithRole

func (f *Service) CanPerformWithRole(owner *string, user string, role per.Role) (bool, *gz.ErrMsg)

CanPerformWithRole checks if the 'owner' arg is an organization or a user. If the 'owner' is an organization, it verifies that the given 'user' arg is authorized to act as the given Role (or above) in the organization. If the 'owner' is a user, it verifies that the 'user' arg is the same as the owner. As a third alternative, if 'owner' is nil then it checks if the 'user' is part of the System Admins.

func (*Service) GetOrganization

func (f *Service) GetOrganization(username string) (*users.Organization, *gz.ErrMsg)

GetOrganization gets a user's organization database entry from the username

func (*Service) GetUserFromUsername

func (f *Service) GetUserFromUsername(username string) (*users.User, *gz.ErrMsg)

GetUserFromUsername returns the user database entry from the username

func (*Service) IsAuthorizedForResource

func (f *Service) IsAuthorizedForResource(user, resource string, action per.Action) (bool, *gz.ErrMsg)

IsAuthorizedForResource checks if user has the permission to perform an action on a resource.

func (*Service) IsSystemAdmin

func (f *Service) IsSystemAdmin(user string) bool

IsSystemAdmin returns a bool indicating if the given user is a system admin.

func (*Service) QueryForResourceVisibility

func (f *Service) QueryForResourceVisibility(q *gorm.DB, owner *string, user *users.User) *gorm.DB

QueryForResourceVisibility checks the relationship between requestor (user) and the resource owner to formulate a database query to determine whether a resource is visible to the user

func (*Service) StartAutoLoadPolicy

func (f *Service) StartAutoLoadPolicy()

StartAutoLoadPolicy starts the auto load remote policy

func (*Service) UserFromJWT

func (f *Service) UserFromJWT(r *http.Request) (*users.User, bool, *gz.ErrMsg)

UserFromJWT returns the User associated to the http request's JWT token. This function can return ErrorAuthJWTInvalid if the token cannot be read, or ErrorAuthNoUser no user with such identity exists in the DB.

func (*Service) VerifyOwner

func (f *Service) VerifyOwner(owner, user string, p per.Action) (bool, *gz.ErrMsg)

VerifyOwner checks if the 'owner' arg is an organization or a user. If the 'owner' is an organization, it verifies that the given 'user' arg has the expected permission in the organization. If the 'owner' is a user, it verifies that the 'user' arg is the same as the owner. Dev note: this is an alternative implementation of ign-fuelserver UserService's VerifyOwner.

Jump to

Keyboard shortcuts

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