How do I verify the contents of an endpoint that downloads a zip file containing a csv file?

398 views
Skip to first unread message

Shelley Tong

unread,
Feb 22, 2018, 3:01:20 PM2/22/18
to REST assured

I have a endpoint I want to test out. I'll call GET with it and it's supposed to download a zip file containing a csv file. I want to verify that the contents of that csv file is correct.

When I hit the endpoint in Postman, the headers look something like this:

content-disposition: "attachment; filename=filename.zip"

content-encoding: gzip content-length: 4321

content-type: "application/zip"

vary: Accept-encoding


On the Rest-Assured response though, when I printed out response.contentType(), I got text/html; charset=utf-8. I was going to try to try to get the response byte in bytes[] and then see if it matches the content I'm expecting in the CSV file but since the content-typedoesn't match what I'm expecting, I don't think I can do that.

Also, how do I check the content-disposition of my response?

Any pointers?

Todd Bradley

unread,
Feb 22, 2018, 3:40:12 PM2/22/18
to rest-a...@googlegroups.com
If the server is sending you back a text/html response, it's probably not the .zip file you're expecting. Are you sure you're sending the correct Accepts headers in your request?

Once you do get a response that contains a .zip file, then you could extract the body as a byte[] or a String or an InputStream that you could send to a file. Do whatever is easiest for what you want to check about the contents of the .zip file.

Lastly, Content-Disposition is just a header on a response, right? How do you test to make sure other headers are what you expect?


Todd.


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages