repository

package
v0.0.0-...-57b459a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey interface {
	GetAPIKey(appID string, key string) (entity.APIKey, error)
	CreateAPIKey(input entity.APIKeyInput) (entity.APIKey, error)
}

APIKey accesses API keys for third party apps from persistent storage, such as database.

type APIKeyFake

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

APIKeyFake represents in memory implementation of APIKey repository

func NewAPIKeyFake

func NewAPIKeyFake(apiKeys []entity.APIKey) APIKeyFake

NewAPIKeyFake creates in memory implementation of APIKey repository.

func (*APIKeyFake) CreateAPIKey

func (a *APIKeyFake) CreateAPIKey(input entity.APIKeyInput) (entity.APIKey, error)

CreateAPIKey creates an api key for a given app.

func (APIKeyFake) GetAPIKey

func (a APIKeyFake) GetAPIKey(appID string, key string) (entity.APIKey, error)

GetAPIKey fetches an api key for a given app.

type AccountMapping

type AccountMapping interface {
	IsSSOUserExist(ssoUser entity.SSOUser) (bool, error)
	CreateMapping(ssoUser entity.SSOUser, user entity.User) error
}

AccountMapping accesses account mapping between SSOUser and internal User from storage media, such as database.

type AccountMappingFake

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

AccountMappingFake represents in memory implementation of AccountMapping repository.

func NewAccountMappingFake

func NewAccountMappingFake(
	ssoUsers []entity.SSOUser,
	users []entity.User) (AccountMappingFake, error)

NewAccountMappingFake creates in memory implementation of AccountMapping repository.

func (*AccountMappingFake) CreateMapping

func (a *AccountMappingFake) CreateMapping(ssoUser entity.SSOUser, user entity.User) error

CreateMapping links an external user with an internal user.

func (AccountMappingFake) IsRelationExist

func (a AccountMappingFake) IsRelationExist(ssoUser entity.SSOUser, user entity.User) bool

IsRelationExist checks whether a given external user is linked to a given internal user.

func (AccountMappingFake) IsSSOUserExist

func (a AccountMappingFake) IsSSOUserExist(ssoUser entity.SSOUser) (bool, error)

IsSSOUserExist checks whether a external user is linked to any internal user.

type App

type App interface {
	GetAppByID(id string) (entity.App, error)
}

App accesses third party app info from persistent storage, such as database.

type AppFake

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

AppFake represents in memory implementation of App repository

func NewAppFake

func NewAppFake(apps []entity.App) AppFake

NewAppFake create in-memory implementation of App repository.

func (AppFake) GetAppByID

func (a AppFake) GetAppByID(id string) (entity.App, error)

GetAppByID fetches an app with given ID from memory.

type ChangeLog

type ChangeLog interface {
	GetChangeLog() ([]entity.Change, error)
	CreateChange(newChange entity.Change) (entity.Change, error)
	DeleteChange(id string) error
	UpdateChange(newChange entity.Change) (entity.Change, error)
}

ChangeLog accesses changelog from storage, such as database.

type ChangeLogFake

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

ChangeLogFake represents in memory implementation of ChangeLog repository

func NewChangeLogFake

func NewChangeLogFake(changeLog []entity.Change) ChangeLogFake

NewChangeLogFake creates ChangeLogFake

func (*ChangeLogFake) CreateChange

func (c *ChangeLogFake) CreateChange(newChange entity.Change) (entity.Change, error)

CreateChange creates and persists new Change in the repository

func (*ChangeLogFake) DeleteChange

func (c *ChangeLogFake) DeleteChange(id string) error

DeleteChange removes a change based on a given id

func (ChangeLogFake) GetChangeLog

func (c ChangeLogFake) GetChangeLog() ([]entity.Change, error)

GetChangeLog fetches full ChangeLog from memory

func (*ChangeLogFake) UpdateChange

func (c *ChangeLogFake) UpdateChange(newChange entity.Change) (entity.Change, error)

UpdateChange replaces an existing change having given id with updated attributes.

type ErrAliasNotFound

type ErrAliasNotFound struct {
	Alias string
}

ErrAliasNotFound represents no short link entry found with the given alias.

func (ErrAliasNotFound) Error

func (e ErrAliasNotFound) Error() string

type ErrEntryExists

type ErrEntryExists string

ErrEntryExists represents table entry already exists error.

func (ErrEntryExists) Error

func (e ErrEntryExists) Error() string

Error coverts ErrEntryExists into human readable message to easy debugging.

type ErrEntryNotFound

type ErrEntryNotFound string

ErrEntryNotFound represents table entry not found error.

func (ErrEntryNotFound) Error

func (e ErrEntryNotFound) Error() string

Error coverts ErrEntryNotFound into human readable message to easy debugging.

type FeatureToggle

type FeatureToggle interface {
	FindToggleByID(id string) (entity.Toggle, error)
}

FeatureToggle accesses feature toggle from storage, such as database.

type FeatureToggleFake

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

FeatureToggleFake represents in-memory implementation of FeatureToggle repository.

func NewFeatureToggleFake

func NewFeatureToggleFake(toggles map[string]entity.Toggle) FeatureToggleFake

NewFeatureToggleFake creates fake feature toggle repository.

func (FeatureToggleFake) FindToggleByID

func (f FeatureToggleFake) FindToggleByID(id string) (entity.Toggle, error)

FindToggleByID fetches Toggle with given ID.

type SSOMap

type SSOMap interface {
	IsSSOUserExist(ssoUserID string) (bool, error)
	GetShortUserID(ssoUserID string) (string, error)
	CreateMapping(sshUserID string, shortUserID string) error
}

SSOMap accesses account mapping between SSOUser and internal User from storage media, such as database.

type SSOMapFake

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

SSOMapFake represents in memory implementation of SSOMap repository.

func NewsSSOMapFake

func NewsSSOMapFake(
	ssoUserIDs []string,
	userIDs []string) (SSOMapFake, error)

NewsSSOMapFake creates in memory implementation of SSOMapFake repository.

func (*SSOMapFake) CreateMapping

func (s *SSOMapFake) CreateMapping(ssoUserID string, userID string) error

CreateMapping links an external user with an internal user.

func (SSOMapFake) GetShortUserID

func (s SSOMapFake) GetShortUserID(ssoUserID string) (string, error)

GetShortUserID retrieves the internal user ID that is linked to the external user.

func (SSOMapFake) IsRelationExist

func (s SSOMapFake) IsRelationExist(ssoUserID string, userID string) bool

IsRelationExist checks whether a given external user is linked to a given internal user.

func (SSOMapFake) IsSSOUserExist

func (s SSOMapFake) IsSSOUserExist(ssoUserID string) (bool, error)

IsSSOUserExist checks whether a external user is linked to any internal user.

type ShortLink interface {
	IsAliasExist(alias string) (bool, error)
	GetShortLinkByID(ID string) (entity.ShortLink, error)
	GetShortLinkByAlias(alias string, expiringAt time.Time) (entity.ShortLink, error)
	CreateShortLink(shortLinkInput entity.ShortLinkInput) error
	UpdateShortLink(oldAlias string, shortLinkInput entity.ShortLinkInput) (entity.ShortLink, error)
	DeleteShortLink(alias string) error
	GetShortLinksByAliases(aliases []string) ([]entity.ShortLink, error)
}

ShortLink accesses shortLinks from storage, such as database.

type ShortLinkFake

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

ShortLinkFake accesses ShortLink information in short_link table through SQL.

func NewShortLinkFake

func NewShortLinkFake(userShortLinkRepoFake *UserShortLinkFake, shortLinks map[string]entity.ShortLink) ShortLinkFake

NewShortLinkFake creates in memory ShortLink repository

func (s *ShortLinkFake) CreateShortLink(shortLinkInput entity.ShortLinkInput) error

CreateShortLink inserts a new ShortLink into short_link table.

func (s ShortLinkFake) DeleteShortLink(alias string) error

DeleteShortLink deletes an existing user short link from in memory data store.

func (ShortLinkFake) GetShortLinkByAlias

func (s ShortLinkFake) GetShortLinkByAlias(alias string, expiringAt time.Time) (entity.ShortLink, error)

GetShortLinkByAlias finds an ShortLink in short_link table given alias.

func (ShortLinkFake) GetShortLinkByID

func (s ShortLinkFake) GetShortLinkByID(ID string) (entity.ShortLink, error)

IsAliasExist checks whether a given alias exist in short_link table.

func (ShortLinkFake) GetShortLinksByAliases

func (s ShortLinkFake) GetShortLinksByAliases(aliases []string) ([]entity.ShortLink, error)

GetShortLinksByAliases finds all ShortLink for a list of aliases

func (ShortLinkFake) IsAliasExist

func (s ShortLinkFake) IsAliasExist(alias string) (bool, error)

IsAliasExist checks whether a given alias exist in short_link table.

func (s ShortLinkFake) UpdateShortLink(oldAlias string, shortLinkInput entity.ShortLinkInput) (entity.ShortLink, error)

UpdateShortLink updates an existing ShortLink with new properties.

type User

type User interface {
	IsIDExist(id string) (bool, error)
	IsEmailExist(email string) (bool, error)
	GetUserByID(id string) (entity.User, error)
	GetUserByEmail(email string) (entity.User, error)
	CreateUser(user entity.User) error
}

User accesses users' information from storage, such as database.

type UserChangeLog

type UserChangeLog interface {
	GetLastViewedAt(user entity.User) (time.Time, error)
	UpdateLastViewedAt(user entity.User, currentTime time.Time) (time.Time, error)
	CreateRelation(user entity.User, currentTime time.Time) error
}

UserChangeLog accesses user-changelog information from storage, such as database.

type UserChangeLogFake

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

UserChangeLogFake represents in memory implementation of UserChangeLog repository.

func NewUserChangeLogFake

func NewUserChangeLogFake(lastViewedAt map[string]time.Time) UserChangeLogFake

NewUserChangeLogFake creates in memory UserChangeLog repository

func (*UserChangeLogFake) CreateRelation

func (u *UserChangeLogFake) CreateRelation(user entity.User, currentTime time.Time) error

CreateRelation inserts new entry into UserChangeLog repository

func (UserChangeLogFake) GetLastViewedAt

func (u UserChangeLogFake) GetLastViewedAt(user entity.User) (time.Time, error)

GetLastViewedAt retrieves lastViewedAt for user

func (*UserChangeLogFake) UpdateLastViewedAt

func (u *UserChangeLogFake) UpdateLastViewedAt(user entity.User, currentTime time.Time) (time.Time, error)

UpdateLastViewedAt updates lastViewedAt for user to currentTime

type UserFake

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

UserFake represents in memory implementation of user repository.

func NewUserFake

func NewUserFake(users []entity.User) UserFake

NewUserFake create in memory user repository implementation.

func (*UserFake) CreateUser

func (u *UserFake) CreateUser(user entity.User) error

CreateUser creates and persists user in the repository for future access.

func (UserFake) GetUserByEmail

func (u UserFake) GetUserByEmail(email string) (entity.User, error)

GetUserByEmail finds an user with a given email.

func (UserFake) GetUserByID

func (u UserFake) GetUserByID(id string) (entity.User, error)

GetUserByID finds an user with a given user ID.

func (UserFake) IsEmailExist

func (u UserFake) IsEmailExist(email string) (bool, error)

IsEmailExist checks whether an user with given email exists in the repository.

func (UserFake) IsIDExist

func (u UserFake) IsIDExist(id string) (bool, error)

IsIDExist checks whether a given user id exists in the repository.

func (UserFake) IsUserIDExist

func (u UserFake) IsUserIDExist(userID string) bool

IsUserIDExist checks whether an user with given ID exists in the repository.

type UserRole

type UserRole interface {
	GetRoles(user entity.User) ([]role.Role, error)
	AddRole(user entity.User, role role.Role) error
	DeleteRole(user entity.User, role role.Role) error
}

UserRole accesses users' role information from storage, such as database.

type UserRoleFake

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

UserRoleFake represents in memory implementation of UserRole repository.

func NewUserRoleFake

func NewUserRoleFake(userRoles map[string][]role.Role) UserRoleFake

NewUserRoleFake creates a new instance of UserRoleFake

func (UserRoleFake) AddRole

func (u UserRoleFake) AddRole(user entity.User, r role.Role) error

AddRole adds the given role to the user

func (UserRoleFake) DeleteRole

func (u UserRoleFake) DeleteRole(user entity.User, r role.Role) error

DeleteRole removes the given role from the user

func (UserRoleFake) GetRoles

func (u UserRoleFake) GetRoles(user entity.User) ([]role.Role, error)

GetRoles fetches roles for the given user

type UserShortLink interface {
	CreateRelation(user entity.User, shortLinkInput entity.ShortLinkInput) error
	GetUserByShortLink(shortLinkID string) (entity.User, error)
	FindAliasesByUser(user entity.User) ([]string, error)
	HasMapping(user entity.User, alias string) (bool, error)
}

UserShortLink accesses User-ShortLink relationship from storage, such as database.

type UserShortLinkFake

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

UserShortLinkFake represents in memory implementation of User-ShortLink relationship accessor.

func NewUserShortLinkRepoFake

func NewUserShortLinkRepoFake(users []entity.User, shortLinks []entity.ShortLink) UserShortLinkFake

NewUserShortLinkRepoFake creates UserShortLinkFake

func (*UserShortLinkFake) CreateRelation

func (u *UserShortLinkFake) CreateRelation(user entity.User, shortLinkInput entity.ShortLinkInput) error

CreateRelation creates many to many relationship between User and ShortLink.

func (UserShortLinkFake) FindAliasesByUser

func (u UserShortLinkFake) FindAliasesByUser(user entity.User) ([]string, error)

FindAliasesByUser fetches the aliases of all the ShortLinks created by the given user.

func (u *UserShortLinkFake) GetUserByShortLink(shortLinkID string) (entity.User, error)

func (UserShortLinkFake) HasMapping

func (u UserShortLinkFake) HasMapping(user entity.User, alias string) (bool, error)

HasMapping checks whether a given short link belongs to a user.

func (*UserShortLinkFake) UpdateAliasCascade

func (u *UserShortLinkFake) UpdateAliasCascade(oldAlias string, shortLinkInput entity.ShortLinkInput) error

UpdateAliasCascade updates user-shortlink relationships to reflect changes to alias. TODO(issue#958) use eventbus for propagating short link change to all related repos

Jump to

Keyboard shortcuts

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