usecase

package
v0.0.0-...-6aec01b Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	Login(ctx context.Context, username, securityKey string) (entity.AccessToken, error)
}

type AuthUseCase

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

AuthUseCase contains business logic related to authentication.

func NewAuthUseCase

func NewAuthUseCase(
	secret creds.Password,
	users repo.Users,
) *AuthUseCase

NewAuthUseCase create and initializes new AuthUseCase object.

func (*AuthUseCase) Login

func (uc *AuthUseCase) Login(
	ctx context.Context,
	username, securityKey string,
) (entity.AccessToken, error)

type AuthUseCaseMock

type AuthUseCaseMock struct {
	mock.Mock
}

func (*AuthUseCaseMock) Login

func (m *AuthUseCaseMock) Login(
	ctx context.Context,
	username, securityKey string,
) (entity.AccessToken, error)

type Secrets

type Secrets interface {
	Create(
		ctx context.Context,
		owner uuid.UUID,
		name string,
		kind goph.DataKind,
		metadata, data []byte,
	) (uuid.UUID, error)

	List(ctx context.Context, owner uuid.UUID) ([]entity.Secret, error)
	Get(ctx context.Context, owner, id uuid.UUID) (*entity.Secret, error)

	Update(
		ctx context.Context,
		owner, id uuid.UUID,
		changed []string,
		name string,
		metadata []byte,
		data []byte,
	) error

	Delete(ctx context.Context, owner, id uuid.UUID) error
}

type SecretsUseCase

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

SecretsUseCase contains business logic related to secrets management.

func NewSecretsUseCase

func NewSecretsUseCase(secrets repo.Secrets) *SecretsUseCase

NewSecretsUseCase create and initializes new SecretsUseCase object.

func (*SecretsUseCase) Create

func (uc *SecretsUseCase) Create(
	ctx context.Context,
	owner uuid.UUID,
	name string,
	kind goph.DataKind,
	metadata, data []byte,
) (uuid.UUID, error)

Create creates new secret.

func (*SecretsUseCase) Delete

func (uc *SecretsUseCase) Delete(
	ctx context.Context,
	owner, id uuid.UUID,
) error

Delete removes secret owned by user.

func (*SecretsUseCase) Get

func (uc *SecretsUseCase) Get(
	ctx context.Context,
	owner, id uuid.UUID,
) (*entity.Secret, error)

Get retrieves full secret info from database.

func (*SecretsUseCase) List

func (uc *SecretsUseCase) List(
	ctx context.Context,
	owner uuid.UUID,
) ([]entity.Secret, error)

List returns list of user's secrets.

func (*SecretsUseCase) Update

func (uc *SecretsUseCase) Update(
	ctx context.Context,
	owner, id uuid.UUID,
	changed []string,
	name string,
	metadata []byte,
	data []byte,
) error

Update changes secret info and data.

type SecretsUseCaseMock

type SecretsUseCaseMock struct {
	mock.Mock
}

func (*SecretsUseCaseMock) Create

func (m *SecretsUseCaseMock) Create(
	ctx context.Context,
	owner uuid.UUID,
	name string,
	kind goph.DataKind,
	metadata, data []byte,
) (uuid.UUID, error)

func (*SecretsUseCaseMock) Delete

func (m *SecretsUseCaseMock) Delete(
	ctx context.Context,
	owner, id uuid.UUID,
) error

func (*SecretsUseCaseMock) Get

func (m *SecretsUseCaseMock) Get(
	ctx context.Context,
	owner, id uuid.UUID,
) (*entity.Secret, error)

func (*SecretsUseCaseMock) List

func (m *SecretsUseCaseMock) List(
	ctx context.Context,
	owner uuid.UUID,
) ([]entity.Secret, error)

func (*SecretsUseCaseMock) Update

func (m *SecretsUseCaseMock) Update(
	ctx context.Context,
	owner, id uuid.UUID,
	changed []string,
	name string,
	metadata []byte,
	data []byte,
) error

type UseCases

type UseCases struct {
	Auth    Auth
	Secrets Secrets
	Users   Users
}

UseCases is a collection of business logic use cases.

func New

func New(cfg *config.Config, repos *repo.Repositories) *UseCases

New creates and initializes collection of business logic use cases.

type Users

type Users interface {
	Register(ctx context.Context, username, securityKey string) (entity.AccessToken, error)
}

type UsersUseCase

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

UsersUseCase contains business logic related to users management.

func NewUsersUseCase

func NewUsersUseCase(secret creds.Password, users repo.Users) *UsersUseCase

NewUsersUseCase create and initializes new UsersUseCase object.

func (UsersUseCase) Register

func (uc UsersUseCase) Register(
	ctx context.Context,
	username, securityKey string,
) (entity.AccessToken, error)

Register creates a new user.

type UsersUseCaseMock

type UsersUseCaseMock struct {
	mock.Mock
}

func (*UsersUseCaseMock) Register

func (m *UsersUseCaseMock) Register(
	ctx context.Context,
	username, securityKey string,
) (entity.AccessToken, error)

Jump to

Keyboard shortcuts

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