-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dne 12.4.2010 18:14, Klaus Kaempf napsal(a):
* Lukas Ocilka <lukas.ocilka@suse.cz> [Apr 12. 2010 16:19]:
Hi,
We've found out that our RoR-based application can crash if broken XML is sent as a request to the application REST API.
I've tried to create a test case that simulates sending XML - as found on several forums and howtos - by using @request.env['RAW_POST_DATA'] but this variable seems to be ignored during the test. See the attached file, please.
Hmm, what makes you think RAW_POST_DATA gets ignored ?
- From what I've seen, the RAW_POST_DATA should be used as the request input processed by the Rails core, not by the controller itself. Controller should work independently on the used method: testcase / curl. So, maybe I'm wrong here. If I send the very same XML via curl --data-binary, it works correctly.
How does the receiving end (CustomersController) look like ?
A common rails-generated controller, nothing special. It doesn't read the request itself.
According to the Rails documentation, the request.body() is delivered as a StringIO. So you need request.body.read() to access its contents.
That's why I'm asking how to test the REST API. I, of course, know how to test controller with correct data, e.g., using a hash of params, but this time I need to create a test-case that sends incorrect data (broken XML) to the application REST API. The application has to render a exception-catch page which I want to have tested. Thx Lukas -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iD8DBQFLxD0kVSqMdRCqTiwRAo/2AJ4o0eyvRYk0HLSgabSeqPu0A7hXbACdGvIe l1BVQFmTxpeUBSMGqyoyTJY= =ZyVI -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-ruby+help@opensuse.org