func (t *TestCase) Validate(resp *resty.Response, ctx *Context) (bool, []error) {
	if ctx == nil {
		return false, []error{t.AppErr("error Valdate:rulectx == nil")}
	}
	t.Body = resp.String()
	if len(t.Body) == 0 {
		logrus.WithField("testcase", t.String()).Debug("Validate: resty.body is empty")
	}
	t.Header = resp.Header()
	pass, errs := t.ApplyExpects(resp, ctx)

	var failures []schema.Failure
	if t.Expect.SchemaValidation {
		if t.Validator == nil {
			return false, []error{t.AppErr("Validate: schema validator is nil")}
		}

		var err error
		failures, err = t.Validator.Validate(schema.HTTPResponse{
			Method:     t.Input.Method,
			Path:       t.Input.Endpoint,
			Header:     resp.Header(),
			Body:       strings.NewReader(t.Body),
			StatusCode: resp.StatusCode(),
		})
		if err != nil {
			return false, []error{t.AppErr("Validate: " + err.Error())}
		}
		for _, failure := range failures {
			errs = append(errs, errors.New(failure.Message))
		}
	} else {
		logSchemaValidationOffWarning(t)
	}

	// Apply Signature Validator
	if t.ValidateSignature && !disableJws {
		xJwsSignature := resp.Header().Get("x-jws-signature")
		logrus.Warn("Validating Signature: " + xJwsSignature)
		logrus.Warn("body: ", t.Body)
		valid, err := validateSignature(xJwsSignature, t.Body, ctx)
		if err != nil {
			return false, []error{t.AppErr("Signature validation failed: " + err.Error())}
		}
		if !valid {
			errs = append(errs, errors.New("Invalid x-jws-signature found - unable to validate"))
		} else {
			logrus.Infoln("x-jws-signature validation succeded")
		}
	}

	// Gather fields within json response - for reporting
	collector := schemaprops.GetPropertyCollector()
	collector.CollectProperties(t.Input.Method, t.Input.Endpoint, t.Body, resp.StatusCode())

	return pass, errs
}
// Validate takes the http response that results as a consequence of sending the testcase http
// request to the endpoint implementation. Validate is responsible for checking the http status
// code and running the set of 'Matches' within the 'Expect' object, to determine if all the
// match conditions are met - which would mean the validation passed.
// The context object is passed as part of the validation as its allows the match clauses to
// examine the request object and 'push' response variables into the context object for use
// in downstream test cases which are potentially part of this testcase sequence
// returns true - validation successful
//         false - validation unsuccessful
//         error - adds detail to validation failure
//         NOTE: Validate will only return false if a check fails - no checks = true
Validate takes the http response that results as a consequence of sending the testcase http
request to the endpoint implementation. Validate is responsible for checking the http status
code and running the set of 'Matches' within the 'Expect' object, to determine if all the
match conditions are met - which would mean the validation passed.
The context object is passed as part of the validation as its allows the match clauses to
examine the request object and 'push' response variables into the context object for use
in downstream test cases which are potentially part of this testcase sequence
returns true - validation successful
false - validation unsuccessful
error - adds detail to validation failure
NOTE: Validate will only return false if a check fails - no checks = true
// Validate takes the http response that results as a consequence of sending the testcase http // request to the endpoint implementation . Validate is responsible for checking the http status // code and running the set of ' Matches ' within the ' Expect ' object to determine if all the // match conditions are met - which would mean the validation passed . // The context object is passed as part of the validation as its allows the match clauses to // examine the request object and ' push ' response variables into the context object for use // in downstream test cases which are potentially part of this testcase sequence // returns true - validation successful // false - validation unsuccessful // error - adds detail to validation failure // NOTE : Validate will only return false if a check fails - no checks = true
func (t *TestCase) Validate(resp *resty.Response, ctx *Context) (bool, []error) {
	if ctx == nil {
		return false, []error{t.AppErr("error Valdate:rulectx == nil")}
	}
	t.Body = resp.String()
	if len(t.Body) == 0 {
		logrus.WithField("testcase", t.String()).Debug("Validate: resty.body is empty")
	}
	t.Header = resp.Header()
	pass, errs := t.ApplyExpects(resp, ctx)
	var failures []schema.Failure
	if t.Expect.SchemaValidation {
		if t.Validator == nil {
			return false, []error{t.AppErr("Validate: schema validator is nil")}
		}
		var err error
		failures, err = t.Validator.Validate(schema.HTTPResponse{
			Method:     t.Input.Method,
			Path:       t.Input.Endpoint,
			Header:     resp.Header(),
			Body:       strings.NewReader(t.Body),
			StatusCode: resp.StatusCode(),
		})
		if err != nil {
			return false, []error{t.AppErr("Validate: " + err.Error())}
		}
		for _, failure := range failures {
			errs = append(errs, errors.New(failure.Message))
		}
	} else {
		logSchemaValidationOffWarning(t)
	}
	if t.ValidateSignature && !disableJws {
		xJwsSignature := resp.Header().Get("x-jws-signature")
		logrus.Warn("Validating Signature: " + xJwsSignature)
		logrus.Warn("body: ", t.Body)
		valid, err := validateSignature(xJwsSignature, t.Body, ctx)
		if err != nil {
			return false, []error{t.AppErr("Signature validation failed: " + err.Error())}
		}
		if !valid {
			errs = append(errs, errors.New("Invalid x-jws-signature found - unable to validate"))
		} else {
			logrus.Infoln("x-jws-signature validation succeded")
		}
	}
	collector := schemaprops.GetPropertyCollector()
	collector.CollectProperties(t.Input.Method, t.Input.Endpoint, t.Body, resp.StatusCode())
	return pass, errs
}
func ( t * TestCase ) Validate ( resp * resty . Response , ctx * Context ) ( bool , [ ] error ) { if ctx == nil { return false , [ ] error { t . AppErr ( " " ) } } t . Body = resp . String ( ) if len ( t . Body ) == 0 { logrus . WithField ( " " , t . String ( ) ) . Debug ( " " ) } t . Header = resp . Header ( ) pass , errs := t . ApplyExpects ( resp , ctx ) var failures [ ] schema . Failure if t . Expect . SchemaValidation { if t . Validator == nil { return false , [ ] error { t . AppErr ( " " ) } } var err error failures , err = t . Validator . Validate ( schema . HTTPResponse { Method : t . Input . Method , Path : t . Input . Endpoint , Header : resp . Header ( ) , Body : strings . NewReader ( t . Body ) , StatusCode : resp . StatusCode ( ) , } ) if err != nil { return false , [ ] error { t . AppErr ( " " + err . Error ( ) ) } } for _ , failure := range failures { errs = append ( errs , errors . New ( failure . Message ) ) } } else { logSchemaValidationOffWarning ( t ) } if t . ValidateSignature && ! disableJws { xJwsSignature := resp . Header ( ) . Get ( " " ) logrus . Warn ( " " + xJwsSignature ) logrus . Warn ( " " , t . Body ) valid , err := validateSignature ( xJwsSignature , t . Body , ctx ) if err != nil { return false , [ ] error { t . AppErr ( " " + err . Error ( ) ) } } if ! valid { errs = append ( errs , errors . New ( " " ) ) } else { logrus . Infoln ( " " ) } } collector := schemaprops . GetPropertyCollector ( ) collector . CollectProperties ( t . Input . Method , t . Input . Endpoint , t . Body , resp . StatusCode ( ) ) return pass , errs }
Validate takes the http response that results as a consequence of sending the testcase http
request to the endpoint implementation.
Validate takes the http response that results as a consequence of sending the testcase http request to the endpoint implementation .
// Apply Signature Validator // Gather fields within json response - for reporting