testuser

package
v1.106.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

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

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
}

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