--- a/assets/schema.json Wed Nov 11 23:09:49 2015 -0600
+++ b/assets/schema.json Thu Nov 12 22:52:08 2015 -0600
@@ -37,6 +37,20 @@
"additionalProperties": true
+ "additionalProperties": false, + "filename": {"type": "string"}, + "md5": {"type": "string"}, + "sha256": {"type": "string"} @@ -55,6 +69,13 @@
+ "$ref": "#/definitions/file" --- a/test.go Wed Nov 11 23:09:49 2015 -0600
+++ b/test.go Thu Nov 12 22:52:08 2015 -0600
@@ -1,10 +1,11 @@
@@ -30,6 +31,7 @@
Headers map[string]string `json:"headers"`
Body string `json:"body"`
JSONSchema map[string]interface{} `json:"json-schema"`
+ File map[string]string `json:"file"` type TestFormData struct {
@@ -171,24 +173,63 @@
+ // read the body into a byte array body_byte, err := ioutil.ReadAll(hresp.Body)
- body := string(body_byte[:])
+ // check if we have a file block and check it + if len(req.Response.File) > 0 { + if sha256_digest, ok := req.Response.File["sha256"]; ok { + sum := sha256.Sum256(body_byte) + if fmt.Sprintf("%x", sum) != sha256_digest { + if md5_digest, ok := req.Response.File["md5"]; ok { + sum := md5.Sum(body_byte) - // check if we have a json schema to validate
- if len(req.Response.JSONSchema) != 0 {
- schema_loader := gojsonschema.NewGoLoader(req.Response.JSONSchema)
- body_loader := gojsonschema.NewStringLoader(body)
+ if fmt.Sprintf("%x", sum) != md5_digest { - schema_result, err := gojsonschema.Validate(schema_loader, body_loader)
+ if filename, ok := req.Response.File["filename"]; ok { + file, err := os.Create(filename) + _, err = file.Write(body_byte) + body := string(body_byte[:]) - if schema_result.Valid() != true {
+ // check if we have a json schema to validate + if len(req.Response.JSONSchema) != 0 { + schema_loader := gojsonschema.NewGoLoader(req.Response.JSONSchema) + body_loader := gojsonschema.NewStringLoader(body) + schema_result, err := gojsonschema.Validate(schema_loader, body_loader) + if schema_result.Valid() != true { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/httpbin-download-png.json Thu Nov 12 22:52:08 2015 -0600
@@ -0,0 +1,19 @@
+ "name": "httpbin download png", + "Content-Type": "image/png", + "Content-Length": "8090" + "md5": "5cca6069f68fbf739fce37e0963f21e7", + "sha256": "541a1ef5373be3dc49fc542fd9a65177b664aec01c8d8608f99e6ec95577d8c1",