dbcontrollers

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateEmailEntry = errors.New("User with this email already exists")
View Source
var ErrDuplicateEntrySubString = "Duplicate entry"
View Source
var ErrDuplicateNameEntry = errors.New("User with this name already exists")
View Source
var ErrEmptyProductIDList = errors.New("Request does not contain any product identifiers")
View Source
var ErrEmptyProjectIDList = errors.New("Request does not contain any project identifiers")
View Source
var ErrEmptyUserIDList = errors.New("Request does not contain any user identifiers")
View Source
var ErrEmptyUsersList = errors.New("At least one product user is required")
View Source
var ErrInvalidEmailOrPasswd = errors.New("Invalid email or password")
View Source
var ErrInvalidOwnerCount = errors.New("Product must have a single owner")
View Source
var ErrMissingProductDBString = "" /* 192-byte string literal not displayed */
View Source
var ErrMissingProductUserDBString = "" /* 198-byte string literal not displayed */
View Source
var ErrMissingProjectDBString = "" /* 202-byte string literal not displayed */
View Source
var ErrMissingUserDBString = "" /* 198-byte string literal not displayed */
View Source
var ErrNoProductAssetUpdate = errors.New("Assets for the selected product not found or no change happened")
View Source
var ErrNoProductDetailUpdate = errors.New("Details for the selected product not found or no change happened")
View Source
var ErrNoProductsForUser = errors.New("This user has no products")
View Source
var ErrNoProjectAssetsUpdate = errors.New("Assets for the selected project not found or no change happened")
View Source
var ErrNoProjectDetailsUpdate = errors.New("Details for the selected project not found or no change happened")
View Source
var ErrNoProjectForProduct = errors.New("No projects for this product")
View Source
var ErrNoProjectsForUser = errors.New("This user has no projects")
View Source
var ErrNoUserAssetsUpdate = errors.New("Assets for the selected user not found or no change happened")
View Source
var ErrNoUserSetttingsUpdate = errors.New("Settings for the selected user not found or no change happened")
View Source
var ErrProductExistsString = "Product with name %s already exists"
View Source
var ErrProductNotFound = errors.New("The selected product not found")
View Source
var ErrProductUserNotAssociated = errors.New("Unable to associate the product with the selected user")
View Source
var ErrProjectExistsString = "Project with name %s already exists"
View Source
var ErrProjectNotFound = errors.New("The selected project not found")
View Source
var ErrProjectViewerNotFound = errors.New("The selected project viewer not found")
View Source
var ErrUnknownPrivilegeString = "Unknown privilege %d set for user %s"
View Source
var ErrUserIsNotConnectedToAnyViewer = errors.New("User is not connected to any viewer")
View Source
var ErrUserNotFound = errors.New("The selected user not found")
View Source
var ErrViewerAlreadyExists = errors.New("Viewer already exists")

Functions

This section is empty.

Types

type DBConnectorMock

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

DBConnectorMock overwrites the mysqldb package implementations for DB connectionwith mock code.

func (*DBConnectorMock) BootstrapSystem

func (i *DBConnectorMock) BootstrapSystem() error

func (*DBConnectorMock) Commit

func (i *DBConnectorMock) Commit(tx *sql.Tx) error

func (*DBConnectorMock) ConnectSystem

func (i *DBConnectorMock) ConnectSystem() (*sql.Tx, error)

func (DBConnectorMock) Rollback

func (i DBConnectorMock) Rollback(tx *sql.Tx) error

type DBControllerCommon

type DBControllerCommon interface {
	CreateProduct(name string, owner *uuid.UUID, generateAssetPath func(assetID *uuid.UUID) (string, error)) (*models.Product, error)
	DeleteProduct(productID *uuid.UUID) error
	GetProduct(productID *uuid.UUID) (*models.ProductData, error)
	UpdateProductDetails(details *models.Asset) error
	UpdateProductAssets(assets *models.Asset) error

	CreateUser(
		name string,
		email string,
		passwd []byte,
		generateAssetPath func(assetID *uuid.UUID) string,
		encryptPassword func(password []byte) ([]byte, error)) (*models.User, error)
	DeleteUser(ID *uuid.UUID, nominatedOwners map[uuid.UUID]uuid.UUID) error
	GetUser(userID *uuid.UUID) (*models.UserData, error)
	UpdateUserSettings(settings *models.Asset) error
	UpdateUserAssets(assets *models.Asset) error
	Authenticate(email string, passwd []byte, authenticate func(string, []byte, *models.User) error) error
}

type DBFunctionMock added in v0.0.10

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

DBFunctionMock overwrites the mysqldb package function implementations with mock code.

func (*DBFunctionMock) AddAsset added in v0.0.10

func (i *DBFunctionMock) AddAsset(assetType string, asset *models.Asset, tx *sql.Tx) error

func (*DBFunctionMock) AddProduct added in v0.0.10

func (i *DBFunctionMock) AddProduct(product *models.Product, tx *sql.Tx) error

func (*DBFunctionMock) AddProductUsers added in v0.0.10

func (i *DBFunctionMock) AddProductUsers(productID *uuid.UUID, productUsers *models.ProductUserIDs, tx *sql.Tx) error

func (DBFunctionMock) AddProject added in v0.0.10

func (i DBFunctionMock) AddProject(project *models.Project, tx *sql.Tx) error

func (*DBFunctionMock) AddProjectUsers added in v0.0.10

func (i *DBFunctionMock) AddProjectUsers(projectID *uuid.UUID, projectUsers *models.ProjectUserIDs, tx *sql.Tx) error

func (*DBFunctionMock) AddProjectViewer added in v0.0.21

func (i *DBFunctionMock) AddProjectViewer(projectViewer *models.ProjectViewer, tx *sql.Tx) error

func (*DBFunctionMock) AddUser added in v0.0.10

func (i *DBFunctionMock) AddUser(user *models.User, tx *sql.Tx) error

func (*DBFunctionMock) DeleteAsset added in v0.0.10

func (i *DBFunctionMock) DeleteAsset(assetType string, assetID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProduct added in v0.0.10

func (i *DBFunctionMock) DeleteProduct(productID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProductUser added in v0.0.10

func (i *DBFunctionMock) DeleteProductUser(productID *uuid.UUID, userID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProductUsersByProductID added in v0.0.10

func (i *DBFunctionMock) DeleteProductUsersByProductID(productID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProject added in v0.0.10

func (i *DBFunctionMock) DeleteProject(projectID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProjectUsersByProjectID added in v0.0.10

func (i *DBFunctionMock) DeleteProjectUsersByProjectID(projectID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProjectViewerByProjectID added in v0.0.21

func (i *DBFunctionMock) DeleteProjectViewerByProjectID(projectID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProjectViewerByUserID added in v0.0.21

func (i *DBFunctionMock) DeleteProjectViewerByUserID(userID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProjectViewerByViewerID added in v0.0.21

func (i *DBFunctionMock) DeleteProjectViewerByViewerID(viewerID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteProjectsByProductID added in v0.0.10

func (i *DBFunctionMock) DeleteProjectsByProductID(productID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteUser added in v0.0.10

func (i *DBFunctionMock) DeleteUser(userID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) DeleteViewerByOwnerID added in v0.0.21

func (i *DBFunctionMock) DeleteViewerByOwnerID(userID *uuid.UUID, tx *sql.Tx) error

func (*DBFunctionMock) GetAsset added in v0.0.10

func (i *DBFunctionMock) GetAsset(assetType string, assetID *uuid.UUID) (*models.Asset, error)

func (*DBFunctionMock) GetAssets added in v0.0.10

func (i *DBFunctionMock) GetAssets(assetType string, IDs []uuid.UUID, tx *sql.Tx) ([]models.Asset, error)

func (*DBFunctionMock) GetPrivilege added in v0.0.10

func (i *DBFunctionMock) GetPrivilege(name string) (*models.Privilege, error)

func (*DBFunctionMock) GetPrivileges added in v0.0.10

func (i *DBFunctionMock) GetPrivileges() (models.Privileges, error)

func (*DBFunctionMock) GetProductByID added in v0.0.10

func (i *DBFunctionMock) GetProductByID(ID *uuid.UUID, tx *sql.Tx) (*models.Product, error)

func (*DBFunctionMock) GetProductByName added in v0.0.10

func (i *DBFunctionMock) GetProductByName(name string, tx *sql.Tx) (*models.Product, error)

func (*DBFunctionMock) GetProductProjects added in v0.0.12

func (i *DBFunctionMock) GetProductProjects(productID *uuid.UUID, tx *sql.Tx) ([]models.Project, error)

func (*DBFunctionMock) GetProductUserIDs added in v0.0.10

func (i *DBFunctionMock) GetProductUserIDs(productID *uuid.UUID, tx *sql.Tx) (*models.ProductUserIDs, error)

func (*DBFunctionMock) GetProductsByIDs added in v0.0.10

func (i *DBFunctionMock) GetProductsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Product, error)

func (*DBFunctionMock) GetProjectByID added in v0.0.10

func (i *DBFunctionMock) GetProjectByID(ID *uuid.UUID, tx *sql.Tx) (*models.Project, error)

func (*DBFunctionMock) GetProjectViewersByUserID added in v0.0.21

func (i *DBFunctionMock) GetProjectViewersByUserID(userID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)

func (*DBFunctionMock) GetProjectViewersByViewerID added in v0.0.21

func (i *DBFunctionMock) GetProjectViewersByViewerID(viewerID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)

func (*DBFunctionMock) GetProjectsByIDs added in v0.0.10

func (i *DBFunctionMock) GetProjectsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Project, error)

func (*DBFunctionMock) GetUser added in v0.0.10

func (i *DBFunctionMock) GetUser(queryType int, keyValue interface{}, tx *sql.Tx) (*models.User, error)

func (*DBFunctionMock) GetUserProductIDs added in v0.0.10

func (i *DBFunctionMock) GetUserProductIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProductIDs, error)

func (*DBFunctionMock) GetUserProjectIDs added in v0.0.10

func (i *DBFunctionMock) GetUserProjectIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProjectIDs, error)

func (*DBFunctionMock) GetUsersByIDs added in v0.0.10

func (i *DBFunctionMock) GetUsersByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.User, error)

func (*DBFunctionMock) UpdateAsset added in v0.0.10

func (i *DBFunctionMock) UpdateAsset(assetType string, asset *models.Asset) error

func (*DBFunctionMock) UpdateUsersProducts added in v0.0.10

func (i *DBFunctionMock) UpdateUsersProducts(userID *uuid.UUID, productID *uuid.UUID, privilege int, tx *sql.Tx) error

func (*DBFunctionMock) UpdateUsersProjects added in v0.0.10

func (i *DBFunctionMock) UpdateUsersProjects(userID *uuid.UUID, projectID *uuid.UUID, privilege int, tx *sql.Tx) error

type MYSQLController

type MYSQLController struct {
	DBFunctions    mysqldb.FunctionsCommon
	DBConnector    mysqldb.ConnectorCommon
	ModelFunctions models.ModelFunctionsCommon
}

func NewDBController

func NewDBController() (*MYSQLController, error)

func (*MYSQLController) AddProductUser

func (c *MYSQLController) AddProductUser(productID *uuid.UUID, userID *uuid.UUID, privilege int) error

func (*MYSQLController) Authenticate

func (c *MYSQLController) Authenticate(
	userID *uuid.UUID,
	email string,
	password string,
	authenticate func(string, string, *models.User) error) error

func (*MYSQLController) CreateProduct

func (c *MYSQLController) CreateProduct(name string, owner *uuid.UUID) (*models.ProductData, error)

func (*MYSQLController) CreateProject

func (c *MYSQLController) CreateProject(
	name string,
	visibility string,
	owner *uuid.UUID,
	productID *uuid.UUID) (*models.ProjectData, error)

func (*MYSQLController) CreateProjectViewer added in v0.0.21

func (c *MYSQLController) CreateProjectViewer(projectViewer *models.ProjectViewer) error

func (*MYSQLController) CreateUser

func (c *MYSQLController) CreateUser(
	name string,
	email string,
	passwd []byte) (*models.UserData, error)

func (*MYSQLController) DeleteProduct

func (c *MYSQLController) DeleteProduct(productID *uuid.UUID) error

func (*MYSQLController) DeleteProductUser

func (c *MYSQLController) DeleteProductUser(productID *uuid.UUID, userID *uuid.UUID) error

func (*MYSQLController) DeleteProject

func (c *MYSQLController) DeleteProject(projectID *uuid.UUID) error

func (*MYSQLController) DeleteProjectViewerByUserID added in v0.0.21

func (c *MYSQLController) DeleteProjectViewerByUserID(userID *uuid.UUID) error

func (*MYSQLController) DeleteProjectViewerByViewerID added in v0.0.21

func (c *MYSQLController) DeleteProjectViewerByViewerID(viewerID *uuid.UUID) error

func (*MYSQLController) DeleteUser

func (c *MYSQLController) DeleteUser(ID *uuid.UUID, nominatedOwners map[uuid.UUID]uuid.UUID) error

func (*MYSQLController) GetProduct

func (c *MYSQLController) GetProduct(productID *uuid.UUID) (*models.ProductData, error)

func (*MYSQLController) GetProducts

func (c *MYSQLController) GetProducts(productIDs []uuid.UUID) ([]models.ProductData, error)

func (*MYSQLController) GetProductsByUserID

func (c *MYSQLController) GetProductsByUserID(userID *uuid.UUID) ([]models.UserProduct, error)

func (*MYSQLController) GetProject

func (c *MYSQLController) GetProject(projectID *uuid.UUID) (*models.ProjectData, error)

func (*MYSQLController) GetProjectViewersByUserID added in v0.0.21

func (c *MYSQLController) GetProjectViewersByUserID(userID *uuid.UUID) (*[]models.ProjectViewer, error)

func (*MYSQLController) GetProjectViewersByViewerID added in v0.0.21

func (c *MYSQLController) GetProjectViewersByViewerID(viewerID *uuid.UUID) (*[]models.ProjectViewer, error)

func (*MYSQLController) GetProjects

func (c *MYSQLController) GetProjects(projectIDs []uuid.UUID) ([]models.ProjectData, error)

func (*MYSQLController) GetProjectsByProductID added in v0.0.12

func (c *MYSQLController) GetProjectsByProductID(productID *uuid.UUID) ([]models.ProjectData, error)

func (*MYSQLController) GetProjectsByUserID

func (c *MYSQLController) GetProjectsByUserID(userID *uuid.UUID) ([]models.UserProject, error)

func (*MYSQLController) GetUser

func (c *MYSQLController) GetUser(userID *uuid.UUID) (*models.UserData, error)

func (*MYSQLController) GetUserByEmail

func (c *MYSQLController) GetUserByEmail(email string) (*models.UserData, error)

func (*MYSQLController) GetUsers

func (c *MYSQLController) GetUsers(userIDs []uuid.UUID) ([]models.UserData, error)

func (*MYSQLController) GetUsersByProductID

func (c *MYSQLController) GetUsersByProductID(productID *uuid.UUID) ([]models.ProductUser, error)

func (*MYSQLController) UpdateProductAssets

func (c *MYSQLController) UpdateProductAssets(productData *models.ProductData) error

func (*MYSQLController) UpdateProductDetails

func (c *MYSQLController) UpdateProductDetails(productData *models.ProductData) error

func (*MYSQLController) UpdateProductUser

func (c *MYSQLController) UpdateProductUser(productID *uuid.UUID, userID *uuid.UUID, privilege int) error

func (*MYSQLController) UpdateProjectAssets

func (c *MYSQLController) UpdateProjectAssets(projectData *models.ProjectData) error

func (*MYSQLController) UpdateProjectDetails

func (c *MYSQLController) UpdateProjectDetails(projectData *models.ProjectData) error

func (*MYSQLController) UpdateProjectUser

func (c *MYSQLController) UpdateProjectUser(projectID *uuid.UUID, userID *uuid.UUID, privilege int) error

func (*MYSQLController) UpdateUserAssets

func (c *MYSQLController) UpdateUserAssets(userData *models.UserData) error

func (*MYSQLController) UpdateUserSettings

func (c *MYSQLController) UpdateUserSettings(userData *models.UserData) error

type ModelMock added in v0.0.10

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

ModelMock overwrites the models package implementations with mock code.

func (*ModelMock) ClearAsset added in v0.0.11

func (i *ModelMock) ClearAsset(asset *models.Asset, typeString string) error

func (*ModelMock) GetField added in v0.0.11

func (i *ModelMock) GetField(asset *models.Asset, typeString string, defaultURL string) interface{}

func (*ModelMock) GetFilePath added in v0.0.11

func (i *ModelMock) GetFilePath(asset *models.Asset, typeString string, defaultPath string) string

func (*ModelMock) NewAsset added in v0.0.10

func (i *ModelMock) NewAsset(references models.DataMap) (*models.Asset, error)

func (*ModelMock) NewProduct added in v0.0.10

func (i *ModelMock) NewProduct(name string, detailsID *uuid.UUID, assetsID *uuid.UUID) (*models.Product, error)

func (*ModelMock) NewProject added in v0.0.10

func (i *ModelMock) NewProject(productID *uuid.UUID, detailsID *uuid.UUID, assetsID *uuid.UUID) (*models.Project, error)

func (*ModelMock) NewUser added in v0.0.10

func (i *ModelMock) NewUser(
	name string,
	email string,
	password []byte,
	settingsID uuid.UUID,
	assetsID uuid.UUID) (*models.User, error)

func (*ModelMock) SetField added in v0.0.11

func (i *ModelMock) SetField(asset *models.Asset, typeString string, field interface{})

func (*ModelMock) SetFilePath added in v0.0.11

func (i *ModelMock) SetFilePath(asset *models.Asset, typeString string, extension string) error

Jump to

Keyboard shortcuts

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