parser

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package parser is the package responsible for parsing test cases and istio configuration to be use on test assertionpackage parser

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyAuthorityList indicates an empty Authority list
	ErrEmptyAuthorityList = errors.New("authority list is empty")
	// ErrEmptyMethodList indicates an empty Method list
	ErrEmptyMethodList = errors.New("method list is empty")
	// ErrEmptyURIList indicates an empty URI list
	ErrEmptyURIList = errors.New("URI list is empty")
)

Functions

This section is empty.

Types

type Destination

type Destination struct {
	Host string `yaml:"host"`
	Port Port   `yaml:"port"`
}

Destination define the destination we should assert

type Input

type Input struct {
	Authority string
	Method    string
	URI       string
	Headers   map[string]string
}

Input contains the data structure which will be used to assert

type Parser

type Parser struct {
	TestCases       []*TestCase
	VirtualServices []*v1alpha3.VirtualService
}

Parser contains the parsed files needed to run tests

func New

func New(testfiles, configfiles []string) (*Parser, error)

New parses and loads the testcases and istio configuration files

type Port

type Port struct {
	Number int16 `yaml:"number"`
}

Port define the port of a given Destination

type Request

type Request struct {
	Authority []string          `yaml:"authority"`
	Method    []string          `yaml:"method"`
	URI       []string          `yaml:"uri"`
	Headers   map[string]string `yaml:"headers"`
}

Request define the crafted http request present in the test case file.

func (*Request) Unfold

func (r *Request) Unfold() ([]Input, error)

Unfold returns a list of Input objects constructed by all possibilities defined in the Request object. Ex: Request{Authority: {"www.example.com", "example.com"}, Method: {"GET", "OPTIONS"}}

returns []Input{
	{Authority:"www.example.com", Method: "GET"},
	{Authority:"www.example.com", Method: "OPTIONS"}
	{Authority:"example.com", Method: "GET"},
	{Authority:"example.com", Method: "OPTIONS"},
}

type TestCase

type TestCase struct {
	Description string                                     `yaml:"description"`
	Request     *Request                                   `yaml:"request"`
	Route       []*networkingv1alpha3.HTTPRouteDestination `yaml:"route"`
	Redirect    *networkingv1alpha3.HTTPRedirect           `yaml:"redirect"`
	Rewrite     *networkingv1alpha3.HTTPRewrite            `yaml:"rewrite"`
	Fault       *networkingv1alpha3.HTTPFaultInjection     `yaml:"fault"`
	Headers     *networkingv1alpha3.Headers                `yaml:"headers"`
	WantMatch   bool                                       `yaml:"wantMatch"`
}

TestCase defines the API for declaring unit tests

type TestCaseYAML

type TestCaseYAML struct {
	TestCases []*TestCase `yaml:"testCases"`
}

TestCaseYAML define the list of TestCase

Jump to

Keyboard shortcuts

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