Add keystone user-update test

* add method update_user for identity_client
* add method test_update_user for UserTestJSON

Change-Id: I895c4fa2924c215f0cdbbb073f637ea4e8a5823f
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 4cfeb45..c3abc46 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -102,11 +102,39 @@
         self.client.clear_auth()
 
     @attr(type='smoke')
+    def test_update_user(self):
+        # Test case to check if updating of user attributes is successful.
+        test_user = rand_name('test_user_')
+        self.data.setup_test_tenant()
+        resp, user = self.client.create_user(test_user, self.alt_password,
+                                             self.data.tenant['id'],
+                                             self.alt_email)
+        # Delete the User at the end of this method
+        self.addCleanup(self.client.delete_user, user['id'])
+        # Updating user details with new values
+        u_name2 = rand_name('user2-')
+        u_email2 = u_name2 + '@testmail.tm'
+        resp, update_user = self.client.update_user(user['id'], name=u_name2,
+                                                    email=u_email2,
+                                                    enabled=False)
+        # Assert response body of update user.
+        self.assertEqual(200, resp.status)
+        self.assertEqual(u_name2, update_user['name'])
+        self.assertEqual(u_email2, update_user['email'])
+        self.assertEqual('false', str(update_user['enabled']).lower())
+        # GET by id after updating
+        resp, updated_user = self.client.get_user(user['id'])
+        # Assert response body of GET after updating
+        self.assertEqual(u_name2, updated_user['name'])
+        self.assertEqual(u_email2, updated_user['email'])
+        self.assertEqual('false', str(updated_user['enabled']).lower())
+
+    @attr(type='smoke')
     def test_delete_user(self):
         # Delete a user
-        alt_user2 = rand_name('alt_user_')
+        test_user = rand_name('test_user_')
         self.data.setup_test_tenant()
-        resp, user = self.client.create_user(alt_user2, self.alt_password,
+        resp, user = self.client.create_user(test_user, self.alt_password,
                                              self.data.tenant['id'],
                                              self.alt_email)
         self.assertEquals('200', resp['status'])
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index 47977df..18132ed 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -152,6 +152,14 @@
         body = json.loads(body)
         return resp, body['user']
 
+    def update_user(self, user_id, **kwargs):
+        """Updates a user."""
+        put_body = json.dumps({'user': kwargs})
+        resp, body = self.put('users/%s' % user_id, put_body,
+                              self.headers)
+        body = json.loads(body)
+        return resp, body['user']
+
     def get_user(self, user_id):
         """GET a user."""
         resp, body = self.get("users/%s" % user_id)
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
index 7a00b84..9d44826 100644
--- a/tempest/services/identity/xml/identity_client.py
+++ b/tempest/services/identity/xml/identity_client.py
@@ -172,6 +172,18 @@
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
+    def update_user(self, user_id, **kwargs):
+        """Updates a user."""
+        if 'enabled' in kwargs:
+            kwargs['enabled'] = str(kwargs['enabled']).lower()
+        update_user = Element("user", xmlns=XMLNS, **kwargs)
+
+        resp, body = self.put('users/%s' % user_id,
+                              str(Document(update_user)),
+                              self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
     def get_user(self, user_id):
         """GET a user."""
         resp, body = self.get("users/%s" % user_id, self.headers)