common

package
v0.0.0-...-549d4bb Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestOutputTable string = "table"
	TestOutputCSV   string = "csv"
	Expected        string = "expected"
	Description     string = "description"
	DescOff         string = "off"
	DescOn          string = "on"
	DescOnError     string = "on-error"
	Passed          string = "PASS"
	Failed          string = "FAIL"
	Errored         string = "ERR "
)
View Source
const (
	CheckStr                string = "check"
	EvaluationStr           string = "evaluation"
	AuthorizerEvaluationStr string = "authorizer_evaluation"
	EvaluationsStr          string = "evaluations"
	SubjectSearchStr        string = "subject_search"
	ResourceSearchStr       string = "resource_search"
	ActionSearchStr         string = "action_search"
)
View Source
const (
	ExpectedSet       string = "expected_set"
	ExpectedDecisions string = "expected_decisions"
)

ExpectedSet and ExpectedDecisions name the assertion fields carrying the expected results for the list-returning check types above (Evaluations, SubjectSearch, ResourceSearch, ActionSearch). Those checks pass or fail on whether the endpoint's result list matches this expected list, not on a single boolean outcome, so unlike the other check types they keep "expected": true and use this list to record what a match means.

View Source
const (
	CLIConfigurationFile string = "topaz.json"
)

Variables

View Source
var (
	ErrSkippedAuthorizerAssertion = cerr.NewAsertoError("T10001", codes.Internal, http.StatusInternalServerError, "no authorizer client")
	ErrSkippedDirectoryAssertion  = cerr.NewAsertoError("T10002", codes.Internal, http.StatusInternalServerError, "no directory client")
)
View Source
var RestrictedNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9_.-]*$`)

Functions

func GetBool

func GetBool(msg *structpb.Struct, fieldName string) (bool, bool)

func GetBoolSlice

func GetBoolSlice(msg *structpb.Struct, fieldName string) []bool

func GetString

func GetString(msg *structpb.Struct, fieldName string) (string, bool)

func GetStringSlice

func GetStringSlice(msg *structpb.Struct, fieldName string) []string

func PrintDesc

func PrintDesc(descFlag, description string, result *CheckResult, expected bool)

func PromptYesNo

func PromptYesNo(label string, def bool) bool

func UnmarshalReq

func UnmarshalReq(value *structpb.Value, msg proto.Message) error

Types

type CheckResult

type CheckResult struct {
	Outcome  bool
	Duration time.Duration
	Err      error
	Str      string
}

func (*CheckResult) PrintCSV

func (cr *CheckResult) PrintCSV(w *csv.Writer, index int, expected bool, checkType CheckType, description string)

func (*CheckResult) PrintCSVHeader

func (cr *CheckResult) PrintCSVHeader(w *csv.Writer)

func (*CheckResult) PrintTable

func (cr *CheckResult) PrintTable(w io.Writer, index int, expected bool, checkType CheckType, noColor bool)

type CheckType

type CheckType int
const (
	CheckUnknown CheckType = iota
	Check
	Evaluation
	AuthorizerEvaluation
	Evaluations
	SubjectSearch
	ResourceSearch
	ActionSearch
)

func GetCheckType

func GetCheckType(msg *structpb.Struct) CheckType

type TestExecCmd

type TestExecCmd struct {
	Files   []string `arg:""  default:"assertions.json" help:"path to assertions file" sep:"none" optional:""`
	Stdin   bool     `flag:"" default:"false" help:"read assertions from --stdin"`
	Summary bool     `flag:"" default:"false" help:"display test summary"`
	Format  string   `flag:"" default:"table" help:"output format (table|csv)" enum:"table,csv"`
	Desc    string   `flag:"" default:"off" enum:"off,on,on-error" help:"output descriptions (off|on|on-error)"`
}

type TestResults

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

func NewTestResults

func NewTestResults(assertions []json.RawMessage) *TestResults

func (*TestResults) IncrErrored

func (t *TestResults) IncrErrored()

func (*TestResults) IncrFailed

func (t *TestResults) IncrFailed()

func (*TestResults) IncrPassed

func (t *TestResults) IncrPassed()

func (*TestResults) IncrSkipped

func (t *TestResults) IncrSkipped()

func (*TestResults) Passed

func (t *TestResults) Passed(passed bool)

func (*TestResults) PrintSummary

func (t *TestResults) PrintSummary(w io.Writer)

PrintSummary. #nosec G705 -- CLI output, no HTML context

type TestRunner

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

func NewAuthorizerTestRunner

func NewAuthorizerTestRunner(ctx context.Context, cmd *TestExecCmd, azConfig *azc.Config) (*TestRunner, error)

func NewDirectoryTestRunner

func NewDirectoryTestRunner(ctx context.Context, cmd *TestExecCmd, dsConfig *dsc.Config) (*TestRunner, error)

func NewTestRunner

func NewTestRunner(ctx context.Context, cmd *TestExecCmd, azConfig *azc.Config, dsConfig *dsc.Config) (*TestRunner, error)

func (*TestRunner) Run

func (runner *TestRunner) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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