summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-03-27 11:21:17 -0700
committerEthan Lynn <ethanlynnl@vmware.com>2018-03-27 11:21:17 -0700
commit1b0ca48aa6d542b4d32f04f824b98c50b403ccbc (patch)
treea5032eef1649ec6f26038b8a5b124b70d71b4ae2
parentc321f8e9f582485165c4208ba3a0f6a55f70fc98 (diff)
Add test_post_v2 for IdentityServer
Add test_post_v2 Change-Id: I527659c36a186d832f643ea97f9bea902a6c084b Issue-ID: MULTICLOUD-199 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r--vio/vio/tests/test_proxy_identity_view.py44
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 4ab2f95..19b77de 100644
--- a/vio/vio/tests/test_proxy_identity_view.py
+++ b/vio/vio/tests/test_proxy_identity_view.py
@@ -124,3 +124,47 @@ class TestTokenView(unittest.TestCase):
mock_post.return_value = res
resp = self.view.post(req, "vmware_nova")
self.assertEqual(200, resp.status_code)
+
+ @mock.patch("requests.post")
+ @mock.patch.object(extsys, "get_vim_by_id")
+ def test_post_v2(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)