Merge "Add support for special char in volume metadata"
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index ec732d1..7d2216d 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -43,7 +43,8 @@
# Create metadata for the volume
metadata = {"key1": "value1",
"key2": "value2",
- "key3": "value3"}
+ "key3": "value3",
+ "key4": "<value&special_chars>"}
rsp, body = self.volumes_client.create_volume_metadata(self.volume_id,
metadata)
@@ -59,6 +60,8 @@
self.assertEqual(200, rsp.status)
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertNotIn("key1", body)
+ del metadata["key1"]
+ self.assertThat(body.items(), ContainsAll(metadata.items()))
@test.attr(type='gate')
def test_update_volume_metadata(self):
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 2b500ae..94c1ff6 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -17,6 +17,7 @@
import urllib
from lxml import etree
+from xml.sax.saxutils import escape
from tempest.common.rest_client import RestClientXML
from tempest import config
@@ -358,7 +359,8 @@
post_body = Element('metadata')
for k, v in meta.items():
data = Element('meta', key=k)
- data.append(Text(v))
+ # Escape value to allow for special XML chars
+ data.append(Text(escape(v)))
post_body.append(data)
return post_body