testuser

package
v1.269.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TestEmail    = "test@codesphere.com"
	TestTeamName = "Tests"

	// Default connection parameters.
	DefaultPort         = 5432
	DefaultUser         = "postgres"
	DefaultDBName       = "codesphere"
	DefaultSSLMode      = "disable"
	DefaultDatacenterID = 1
)

Variables

This section is empty.

Functions

func HashAPIToken

func HashAPIToken(apiToken string) string

HashAPIToken hashes an API token using a single SHA256 with no additional salt.

func LogAndPersistResult

func LogAndPersistResult(result *TestUserResult, workdir string)

LogAndPersistResult writes the test user result to a JSON file and logs the credentials.

func WriteResultToFile

func WriteResultToFile(result *TestUserResult, dir string) (string, error)

WriteResultToFile writes the test user result to a JSON file in the given directory.

Types

type CreateTestUserOpts

type CreateTestUserOpts struct {
	Host         string
	Port         int
	User         string
	Password     string
	DBName       string
	SSLMode      string
	DatacenterID int
}

CreateTestUserOpts contains the options for creating a test user.

type TestUserCreator

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

TestUserCreator manages the lifecycle of test user creation.

func New

New creates a new TestUserCreator with the given options.

func (*TestUserCreator) Create

func (c *TestUserCreator) Create() (*TestUserResult, error)

Create generates credentials and inserts the test user into the database.

type TestUserResult

type TestUserResult struct {
	Email             string `json:"email"`
	PlaintextPassword string `json:"password"`
	PlaintextAPIToken string `json:"api_token"`
}

TestUserResult contains the result of creating a test user.

func CreateTestUser

func CreateTestUser(opts CreateTestUserOpts) (*TestUserResult, error)

CreateTestUser is a convenience facade: New -> Create -> close.

Jump to

Keyboard shortcuts

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