testenv

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package testenv provisions an ephemeral Passbolt + MariaDB stack via testcontainers-go so integration tests can talk to a fully-functional server without any external setup.

Sync note: this file is duplicated at go-passbolt-cli/internal/testenv/ passbolt.go. The duplication is intentional so the CLI's standalone CI can compile its integration tests without depending on an unreleased SDK package. When changing one copy, mirror the change in the other and verify with:

diff <repo>/go-passbolt/internal/testenv/passbolt.go \
     <repo>/go-passbolt-cli/internal/testenv/passbolt.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	UserID     string
	Email      string
	Password   string
	PrivateKey string // ASCII-armored, locked with Password.
}

Credentials is everything a test needs to authenticate as a Passbolt user.

type Passbolt

type Passbolt struct {
	BaseURL string
	// contains filtered or unexported fields
}

Passbolt is a running Passbolt instance.

func Start

func Start(ctx context.Context) (*Passbolt, error)

Start brings up MariaDB + Passbolt on a shared Docker network. The caller owns teardown via (*Passbolt).Close. Use StartT from a test function if you want automatic t.Cleanup wiring. Cold start is ~30-60s once images are cached.

func StartT

func StartT(t *testing.T) *Passbolt

StartT is the *testing.T-bound convenience: starts the stack, registers teardown via t.Cleanup, and fatals on error.

func (*Passbolt) Close

func (p *Passbolt) Close(ctx context.Context) error

Close terminates every container/network the stack owns. Safe to call more than once. Errors are joined so that one failed teardown doesn't mask the others.

func (*Passbolt) CreateUser

func (p *Passbolt) CreateUser(ctx context.Context, email, first, last, role, password string) (Credentials, error)

CreateUser invites the user and completes account setup, returning ready-to-use credentials. The returned PrivateKey is ASCII-armored and locked with the supplied password.

func (*Passbolt) EnableV5Resources

func (p *Passbolt) EnableV5Resources(ctx context.Context, admin Credentials) error

EnableV5Resources flips the server-side metadata-type and metadata-key settings so V5 resources can be created. A fresh Passbolt defaults to v4-only (see getV4DefaultMetadataTypeSettings in the api package); without this call, every CreateResource for a v5-* type rejects with "creation of V5 passwords is disabled on this server".

admin must be a user with the "admin" role; the call opens a short-lived admin session and discards it, so caller-side clients still need to be (re-)logged-in after this returns to see the new settings in their cache.

func (*Passbolt) RegisterUser

func (p *Passbolt) RegisterUser(ctx context.Context, email, first, last, role string) (userID, token string, err error)

RegisterUser invites a user via `cake passbolt register_user` and returns the userID and one-time setup token parsed from the printed URL. role must be "user" or "admin".

Jump to

Keyboard shortcuts

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