diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-27 11:31:01 -0700 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-27 11:31:01 -0700 |
commit | a2039ec4efdc527b083a0059b05ae7533820ff51 (patch) | |
tree | 9e7beee0122f081a2d767d57c025f66a3d6fe127 | |
parent | 4723b5d862ca70adfed4eea05c4bd32074509746 (diff) |
Add test_post for TokenV2View
Add test_post
Change-Id: Ie4a3ccabbf5ae9c23d66664234efa397ed885d9c
Issue-ID: MULTICLOUD-199
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r-- | vio/vio/tests/test_proxy_identity_view.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vio/vio/tests/test_proxy_identity_view.py b/vio/vio/tests/test_proxy_identity_view.py index e7b1e15..729fba0 100644 --- a/vio/vio/tests/test_proxy_identity_view.py +++ b/vio/vio/tests/test_proxy_identity_view.py @@ -195,3 +195,47 @@ class TestTokenV2View(unittest.TestCase): mock_get.return_value = res resp = self.view.get(req, "vmware_nova") self.assertEqual(resp.status_code, 200) + + @mock.patch("requests.post") + @mock.patch.object(extsys, "get_vim_by_id") + def test_post(self, mock_getvim, mock_post): + req = mock.Mock() + req.get_full_path.return_value = "identity/v2.0/tokens" + req.body = """{ + "auth": { + "tenantName": "tenant-name", + "passwordCredentials": { + "username": "admin", + "password": "pass" + } + } + }""" + mock_getvim.return_value = { + "url": "http://onap.org/identity/v2.0/tokens" + } + res = mock.Mock() + res.status_code = 200 + res.headers = [("X-Subject-Token", "fake-token")] + res.json.return_value = { + "access": { + "token": { + "value": "token-value", + "tenant": { + "id": "tenant-id" + }, + }, + "serviceCatalog": [{ + "type": "volume", + "id": "3e4941704e9941a582b157ac7203ec1b", + "name": "cinder", + "endpoints": [{ + "adminURL": "http://onap.org/api/multicloud/v0/xxx", + "internalURL": "http://onap.org/api/multicloud/v0/xxx", + "publicURL": "http://onap.org/api/multicloud/v0/xxx" + }] + }] + } + } + mock_post.return_value = res + resp = self.view.post(req, "vmware_nova") + self.assertEqual(200, resp.status_code) |