[openstack-dev] [qa][keystone] Help with XML Tempest API tests
Steven Hardy
shardy at redhat.com
Thu Oct 31 19:40:16 UTC 2013
Hi all,
So firstly, if you're an XML guru, I apologize, the questions below are
probably really basic, I always prefer JSON or YAML, because every time I
deal with XML, I get a week-long-headache ;)
So I'm writing Tempest API tests for the keystone OS-TRUST extension, as
was previously requested - it's going pretty well, & I'm finding some real
bugs. Here's a WIP review:
https://review.openstack.org/#/c/54810/
However, I've got a bit stuck formatting the POST body for the trust create
in XML (all works fine via JSON). The json body looks like:
{
"trust": {
"expires_at": "2013-02-27T18:30:59.999999Z",
"impersonation": true,
"project_id": "ddef321",
"roles": [
{
"name": "member"
}
],
"trustee_user_id": "86c0d5",
"trustor_user_id": "a0fdfd"
}
}
And looking at other XML tests which format a POST body, they do something
like:
post_body = Element("trust",
xmlns=XMLNS,
trustor_user_id=trustor_user_id,
trustee_user_id=trustee_user_id,
project_id=project_id,
impersonation=impersonation,
expires_at=expires_at)
This gives me a post body which looks weird (but seems to work):
<trust impersonation="True"
xmlns="http://docs.openstack.org/identity/api/v3"
trustor_user_id="efc6504105c54fbe95928a51459d06c9" expires_at=""
trustee_user_id="f55efd1d617e4367891d202a811d7728"
project_id="b5d498f9631244b59912ce2a0025cf8d"/>
So my questions are:
1. Why do we create a single element like this, instead of appending
subelements so the XML body looks more like the JSON request?
2. If any elements have a None value, they are encoded as a zero-length
string, is that expected?
3. How do I go about encoding the list of roles, as in the sample request
(it's a list of dicts, where each dict has one key called "name")
Any help, review feedback or pointers to docs/examples would be hugely
appreciated!
Thanks,
Steve
More information about the OpenStack-dev
mailing list