Documentation ¶
Index ¶
- Constants
- Variables
- type CreateCmd
- type FakeUserBuilder
- func (f *FakeUserBuilder) Build() *User
- func (f *FakeUserBuilder) BuildAndStore(ctx context.Context, db sqlstorage.Querier) *User
- func (f *FakeUserBuilder) WithAdminRole() *FakeUserBuilder
- func (f *FakeUserBuilder) WithPassword(password string) *FakeUserBuilder
- func (f *FakeUserBuilder) WithStatus(status Status) *FakeUserBuilder
- func (f *FakeUserBuilder) WithUsername(username string) *FakeUserBuilder
- type MockService
- func (_m *MockService) AddToDeletion(ctx context.Context, userID uuid.UUID) error
- func (_m *MockService) Authenticate(ctx context.Context, username string, password secret.Text) (*User, error)
- func (_m *MockService) Bootstrap(ctx context.Context) (*User, error)
- func (_m *MockService) Create(ctx context.Context, user *CreateCmd) (*User, error)
- func (_m *MockService) GetAll(ctx context.Context, paginateCmd *sqlstorage.PaginateCmd) ([]User, error)
- func (_m *MockService) GetAllWithStatus(ctx context.Context, status Status, cmd *sqlstorage.PaginateCmd) ([]User, error)
- func (_m *MockService) GetByID(ctx context.Context, userID uuid.UUID) (*User, error)
- func (_m *MockService) HardDelete(ctx context.Context, userID uuid.UUID) error
- func (_m *MockService) MarkInitAsFinished(ctx context.Context, userID uuid.UUID) (*User, error)
- func (_m *MockService) UpdateUserPassword(ctx context.Context, cmd *UpdatePasswordCmd) error
- type Service
- type Status
- type UpdatePasswordCmd
- type User
Constants ¶
const ( BoostrapUsername = "admin" BoostrapPassword = "duckcloud" )
const ( SecretMinLength = 8 SecretMaxLength = 200 )
Variables ¶
var ( ErrAlreadyExists = fmt.Errorf("user already exists") ErrUsernameTaken = fmt.Errorf("username taken") ErrInvalidUsername = fmt.Errorf("invalid username") ErrInvalidPassword = fmt.Errorf("invalid password") ErrLastAdmin = fmt.Errorf("can't remove the last admin") ErrInvalidStatus = fmt.Errorf("invalid status") )
var ExampleAlice = User{ // contains filtered or unexported fields }
var ExampleBob = User{ // contains filtered or unexported fields }
var ExampleDeletingAlice = User{ // contains filtered or unexported fields }
var ExampleInitializingBob = User{ // contains filtered or unexported fields }
var UsernameRegexp = regexp.MustCompile("^[0-9a-zA-Z-]+$")
Functions ¶
This section is empty.
Types ¶
type FakeUserBuilder ¶
type FakeUserBuilder struct {
// contains filtered or unexported fields
}
func NewFakeUser ¶
func NewFakeUser(t testing.TB) *FakeUserBuilder
func (*FakeUserBuilder) Build ¶
func (f *FakeUserBuilder) Build() *User
func (*FakeUserBuilder) BuildAndStore ¶
func (f *FakeUserBuilder) BuildAndStore(ctx context.Context, db sqlstorage.Querier) *User
func (*FakeUserBuilder) WithAdminRole ¶
func (f *FakeUserBuilder) WithAdminRole() *FakeUserBuilder
func (*FakeUserBuilder) WithPassword ¶
func (f *FakeUserBuilder) WithPassword(password string) *FakeUserBuilder
func (*FakeUserBuilder) WithStatus ¶
func (f *FakeUserBuilder) WithStatus(status Status) *FakeUserBuilder
func (*FakeUserBuilder) WithUsername ¶
func (f *FakeUserBuilder) WithUsername(username string) *FakeUserBuilder
type MockService ¶
MockService is an autogenerated mock type for the Service type
func NewMockService ¶
func NewMockService(t interface { mock.TestingT Cleanup(func()) }) *MockService
NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockService) AddToDeletion ¶
AddToDeletion provides a mock function with given fields: ctx, userID
func (*MockService) Authenticate ¶
func (_m *MockService) Authenticate(ctx context.Context, username string, password secret.Text) (*User, error)
Authenticate provides a mock function with given fields: ctx, username, password
func (*MockService) Bootstrap ¶
func (_m *MockService) Bootstrap(ctx context.Context) (*User, error)
Bootstrap provides a mock function with given fields: ctx
func (*MockService) GetAll ¶
func (_m *MockService) GetAll(ctx context.Context, paginateCmd *sqlstorage.PaginateCmd) ([]User, error)
GetAll provides a mock function with given fields: ctx, paginateCmd
func (*MockService) GetAllWithStatus ¶
func (_m *MockService) GetAllWithStatus(ctx context.Context, status Status, cmd *sqlstorage.PaginateCmd) ([]User, error)
GetAllWithStatus provides a mock function with given fields: ctx, status, cmd
func (*MockService) HardDelete ¶
HardDelete provides a mock function with given fields: ctx, userID
func (*MockService) MarkInitAsFinished ¶
MarkInitAsFinished provides a mock function with given fields: ctx, userID
func (*MockService) UpdateUserPassword ¶
func (_m *MockService) UpdateUserPassword(ctx context.Context, cmd *UpdatePasswordCmd) error
UpdateUserPassword provides a mock function with given fields: ctx, cmd
type Service ¶
type Service interface { Create(ctx context.Context, user *CreateCmd) (*User, error) Bootstrap(ctx context.Context) (*User, error) GetByID(ctx context.Context, userID uuid.UUID) (*User, error) Authenticate(ctx context.Context, username string, password secret.Text) (*User, error) GetAll(ctx context.Context, paginateCmd *sqlstorage.PaginateCmd) ([]User, error) AddToDeletion(ctx context.Context, userID uuid.UUID) error HardDelete(ctx context.Context, userID uuid.UUID) error GetAllWithStatus(ctx context.Context, status Status, cmd *sqlstorage.PaginateCmd) ([]User, error) MarkInitAsFinished(ctx context.Context, userID uuid.UUID) (*User, error) UpdateUserPassword(ctx context.Context, cmd *UpdatePasswordCmd) error }
type UpdatePasswordCmd ¶
func (UpdatePasswordCmd) Validate ¶
func (t UpdatePasswordCmd) Validate() error
type User ¶
type User struct {
// contains filtered or unexported fields
}
User representation