FreeIPA has a set of fixture files: Files that provide static data captured from an RPC that are used for development and unit tests. Here’s how I update them.
Probably the most commonly updated file is install/ui/test/data/ipa_init.json. This file contains the contents of the response for the batch of command fired off at the beginning of a WebUI session. I have a text file with the equivalent commands:
[ayoung@ipa14 ~]$ cat batch_request.json
{"method":"batch","params":[[ {"method":"json_metadata","params":[[],{}]}, {"method":"i18n_messages","params":[[],{}]}, {"method":"user_find","params":[[],{"whoami":"true","all":"true"}]}, {"method":"env","params":[[],{}]}, {"method":"dns_is_enabled","params":[[],{}]} ],{}],"id":1}
Here’s how I update the data:
[ayoung@ipa14 ~]$ curl -v -H "Content-Type:application/json" -H "Accept:applicaton/json" --negotiate -u : --cacert /etc/ipa/ca.crt -d @batch_request.json -X POST https://`hostname`/ipa/json > /home/ayoung/devel/freeipa/install/ui/test/data/ipa_init.json
I’ve discussed the use of curl for talking to IPA elsewhere.
This one was easy because the JSON is spelled out in ipa.js. However, for most requests, the JSON can be captured using firebug by looking in the console window.