utils

package
v0.0.3-beta Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VStore = &VariableStore{values: map[string]interface{}{}}

Functions

func AllowedTest

func AllowedTest(w http.ResponseWriter, r *http.Request)

func CertSetup

func CertSetup(ipAddress string) (serverTLSConf *tls.Config, clientTLSConf *tls.Config, err error)

CertSetup generate a self signed certificate if https is on and no certificate is provided To be used for development purposes only From https://gist.github.com/shaneutt/5e1995295cff6721c89a71d13a71c251 https://shaneutt.com/blog/golang-ca-and-signed-cert-go/

func GetBodyData

func GetBodyData(r *http.Request) (interface{}, error)

GetBodyData tries to get data from body request, as a urlencoded content type or as json by default

func GetBodyMapData

func GetBodyMapData(r *http.Request) (map[string]interface{}, error)

func GetOperation

func GetOperation(r *http.Request) string

func GetPathSegment

func GetPathSegment(r *http.Request, part int) string

func GetRequestParams

func GetRequestParams(request *http.Request) url.Values

func GetSession

func GetSession(w http.ResponseWriter, request *http.Request) *sessions.Session

func GetTableNames

func GetTableNames(r *http.Request, allTableNames []string) []string

func GzCompress

func GzCompress(input string) (string, error)

func GzUncompress

func GzUncompress(input string) (string, error)

func IsServerStarted

func IsServerStarted(url string) bool

func JsonEqual

func JsonEqual(vx, vy interface{}) bool

Equal checks equality between 2 Body-encoded data. https://github.com/emacampolo/gomparator/blob/master/json_util.go

func MinInt

func MinInt(a, b int) int

func NumberFormat

func NumberFormat(number float64, dec int, decPoint, thousandsSep string) string

func RemoveDuplicateStr

func RemoveDuplicateStr(strSlice []string) []string

func RunTests

func RunTests(t *testing.T, serverUrlHttps string, tests []Test)

func SelectConfig

func SelectConfig(ignoreEnvVar bool) string

For tests, if there is no GCA_CONFIG_FILE env var provided, we create a sqlite db and we use a default config file

func TestGetUrl

func TestGetUrl(t *testing.T, url string, response interface{})

Types

type Test

type Test struct {
	Name          string
	Method        string
	Uri           string
	Body          string
	Want          string
	WantRegex     string
	StatusCode    int
	Username      string
	Password      string
	AuthMethod    string
	Jar           http.CookieJar
	RequestHeader map[string]string
	WantHeader    map[string]string
	SkipFor       map[string]bool
	Driver        string
	Server        string
	WantJson      string
}

type VariableStore

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

func (*VariableStore) Get

func (vs *VariableStore) Get(key string) interface{}

func (*VariableStore) Set

func (vs *VariableStore) Set(key string, value interface{})

Jump to

Keyboard shortcuts

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