コード例 #1
0
ファイル: test_auth.py プロジェクト: maxlinc/mimic
 def test_unversioned_entry(self):
     """
     An L{Endpoint} created without a 'prefix' returns a URI without a
     version.
     """
     self.assertEqual(
         get_endpoints(tenant_id="1234",
                       entry_generator=lambda t_id: [
                           Entry(tenant_id=t_id,
                                 type="compute",
                                 name="compute_name",
                                 endpoints=[
                                     Endpoint(tenant_id=t_id,
                                              region="None",
                                              endpoint_id="eid")
                                 ])
                       ],
                       prefix_for_endpoint=lambda ep: "http://prefix/"), {
                           "endpoints": [{
                               "id": "eid",
                               "name": "compute_name",
                               "type": "compute",
                               "region": "None",
                               "tenantId": "1234",
                               "publicURL": "http://prefix/1234"
                           }]
                       })
コード例 #2
0
ファイル: auth_api.py プロジェクト: fnaval/mimic
 def get_service_catalog(self, request, token_id):
     """
     Return a service catalog consisting of nova and load balancer mocked
     endpoints.
     """
     request.setResponseCode(200)
     return json.dumps(get_endpoints(token_id))
コード例 #3
0
ファイル: test_auth.py プロジェクト: lvh/mimic
 def test_unversioned_entry(self):
     """
     An L{Endpoint} created without a 'prefix' returns a URI without a
     version.
     """
     self.assertEqual(
         get_endpoints(
             tenant_id="1234",
             entry_generator=lambda t_id: [Entry(
                 tenant_id=t_id, type="compute",
                 name="compute_name", endpoints=[
                     Endpoint(tenant_id=t_id,
                              region="None",
                              endpoint_id="eid")
                 ]
             )],
             prefix_for_endpoint=lambda ep: "http://prefix/"
         ),
         {
             "endpoints": [
                 {
                     "id": "eid",
                     "name": "compute_name",
                     "type": "compute",
                     "region": "None",
                     "tenantId": "1234",
                     "publicURL": "http://prefix/1234"
                 }
             ]
         }
     )
コード例 #4
0
ファイル: test_auth.py プロジェクト: maxlinc/mimic
    def test_endpoints_response(self):
        """
        :func:`get_endpoints` returns JSON-serializable data in the format
        presented by a ``GET /v2.0/tokens/<token>/endpoints``; i.e. the
        administrative list of tokens.
        """
        tenant_id = 'abcdefg'
        from itertools import count
        accum = count(1)

        def counter():
            return next(accum)

        # Possible TODO for cloudServersOpenStack:

        # "versionInfo": "http://localhost:8902/v2",
        # "versionList": "http://localhost:8902/",
        # "versionId": "2",

        self.assertEqual(
            get_endpoints(tenant_id=tenant_id,
                          entry_generator=example_endpoints(counter),
                          prefix_for_endpoint=lambda e: 'prefix'),
            {
                "endpoints": [{
                    "region": "EXAMPLE_1",
                    "tenantId": "abcdefg_1",
                    "publicURL": "http://ok_1",
                    "name": "something",
                    "type": "compute",
                    "id": 1,
                }, {
                    "region": "EXAMPLE_2",
                    "tenantId": "abcdefg_2",
                    "publicURL": "http://ok_2",
                    "name": "something",
                    "type": "compute",
                    "id": 2,
                }, {
                    "region": "EXAMPLE_1",
                    "tenantId": "abcdefg_1",
                    "publicURL": "http://ok_1",
                    "name": "something_else",
                    "type": "compute",
                    "id": 3,
                }, {
                    "region": "EXAMPLE_2",
                    "tenantId": "abcdefg_2",
                    "publicURL": "http://ok_2",
                    "name": "something_else",
                    "type": "compute",
                    "id": 4
                }]
            },
        )
コード例 #5
0
 def get_endpoints_for_token(self, request, token_id):
     """
     Return a service catalog consisting of nova and load balancer mocked
     endpoints.
     """
     # FIXME: TEST
     request.setResponseCode(200)
     prefix_map = {}
     session = self.core.sessions.session_for_token(token_id)
     return json.dumps(
         get_endpoints(session.tenant_id,
                       entry_generator=lambda tenant_id: list(
                           self.core.entries_for_tenant(
                               tenant_id, prefix_map,
                               base_uri_from_request(request))),
                       prefix_for_endpoint=prefix_map.get))
コード例 #6
0
ファイル: identity_api.py プロジェクト: pratikmallya/mimic
 def get_endpoints_for_token(self, request, token_id):
     """
     Return a service catalog consisting of nova and load balancer mocked
     endpoints.
     """
     # FIXME: TEST
     request.setResponseCode(200)
     prefix_map = {}
     session = self.core.sessions.session_for_token(token_id)
     return json.dumps(get_endpoints(
         session.tenant_id,
         entry_generator=lambda tenant_id: list(
             self.core.entries_for_tenant(tenant_id, prefix_map,
                                          base_uri_from_request(request))),
         prefix_for_endpoint=prefix_map.get)
     )
コード例 #7
0
    def get_endpoints_for_token(self, request, token_id):
        """
        Return a service catalog consisting of nova and load balancer mocked
        endpoints.

        `OpenStack Identity v2 Admin Endpoints for Token
        <http://developer.openstack.org/api-ref/identity/v2-admin/#list-endoints-for-token>`_
        """
        # FIXME: TEST
        request.setResponseCode(200)
        prefix_map = {}
        session = self.core.sessions.session_for_token(token_id)
        return json.dumps(
            get_endpoints(session.tenant_id,
                          entry_generator=lambda tenant_id: list(
                              self.core.entries_for_tenant(
                                  tenant_id, prefix_map,
                                  base_uri_from_request(request))),
                          prefix_for_endpoint=prefix_map.get))
コード例 #8
0
ファイル: identity_api.py プロジェクト: rackerlabs/mimic
    def get_endpoints_for_token(self, request, token_id):
        """
        Return a service catalog consisting of nova and load balancer mocked
        endpoints.

        `OpenStack Identity v2 Admin Endpoints for Token
        <http://developer.openstack.org/api-ref/identity/v2-admin/#list-endoints-for-token>`_
        """
        # FIXME: TEST
        request.setResponseCode(200)
        prefix_map = {}
        session = self.core.sessions.session_for_token(token_id)
        return json.dumps(
            get_endpoints(
                session.tenant_id,
                entry_generator=lambda tenant_id: list(
                    self.core.entries_for_tenant(tenant_id, prefix_map, base_uri_from_request(request))
                ),
                prefix_for_endpoint=prefix_map.get,
            )
        )
コード例 #9
0
ファイル: test_auth.py プロジェクト: lvh/mimic
    def test_endpoints_response(self):
        """
        :func:`get_endpoints` returns JSON-serializable data in the format
        presented by a ``GET /v2.0/tokens/<token>/endpoints``; i.e. the
        administrative list of tokens.
        """
        tenant_id = 'abcdefg'
        from itertools import count
        accum = count(1)

        def counter():
            return next(accum)
        # Possible TODO for cloudServersOpenStack:

        # "versionInfo": "http://localhost:8902/v2",
        # "versionList": "http://localhost:8902/",
        # "versionId": "2",

        self.assertEqual(
            get_endpoints(
                tenant_id=tenant_id,
                entry_generator=example_endpoints(counter),
                prefix_for_endpoint=lambda e: 'prefix'
            ),
            {
                "endpoints": [
                    {
                        "region": "EXAMPLE_1",
                        "tenantId": "abcdefg_1",
                        "publicURL": "http://ok_1",
                        "name": "something",
                        "type": "compute",
                        "id": 1,
                    },
                    {
                        "region": "EXAMPLE_2",
                        "tenantId": "abcdefg_2",
                        "publicURL": "http://ok_2",
                        "name": "something",
                        "type": "compute",
                        "id": 2,
                    },
                    {
                        "region": "EXAMPLE_1",
                        "tenantId": "abcdefg_1",
                        "publicURL": "http://ok_1",
                        "name": "something_else",
                        "type": "compute",
                        "id": 3,
                    },
                    {
                        "region": "EXAMPLE_2",
                        "tenantId": "abcdefg_2",
                        "publicURL": "http://ok_2",
                        "name": "something_else",
                        "type": "compute",
                        "id": 4
                    }
                ]
            },
        )