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
- func PassboltImage() string
- type Credentials
- type Passbolt
- func (p *Passbolt) Close(ctx context.Context) error
- func (p *Passbolt) CreateUser(ctx context.Context, email, first, last, role, password string) (Credentials, error)
- func (p *Passbolt) EnableV5Resources(ctx context.Context, admin Credentials) error
- func (p *Passbolt) RegisterUser(ctx context.Context, email, first, last, role string) (userID, token string, err error)
Constants ¶
const ( // PassboltImageEnv names the environment variable that overrides // defaultPassboltImage, so the same suite can be replayed against several // Passbolt releases (see scripts/test-matrix.sh). An override is // deliberately tag-only: pinning a digest per version would mean tracking // ~15 digests by hand. MariaDB stays pinned either way — it is not the // variable under test. PassboltImageEnv = "PASSBOLT_TEST_IMAGE" )
Pinned by tag AND digest so every CI run and every developer machine pulls byte-identical images. Bumping the tag without bumping the digest (or vice versa) is a deliberate, reviewable change. Refresh both together when moving to a new Passbolt release.
Variables ¶
This section is empty.
Functions ¶
func PassboltImage ¶ added in v0.8.2
func PassboltImage() string
PassboltImage reports the Passbolt image the next Start will use: the PASSBOLT_TEST_IMAGE override when set and non-blank, otherwise the pinned default.
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 ¶
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 ¶
StartT is the *testing.T-bound convenience: starts the stack, registers teardown via t.Cleanup, and fatals on error.
func (*Passbolt) Close ¶
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".