Esempio n. 1
0
    def test_get_image_remote(self):
        REMOTE_PROJECT_ID = "319d8162b38342609f5fafe1404216b9"
        LOCAL_TOKEN = "my-local-token"
        REMOTE_TOKEN = "my-remote-token"

        self.session_fixture.add_sp_auth('remote1', LOCAL_TOKEN,
                                         REMOTE_PROJECT_ID, REMOTE_TOKEN)
        insert(
            ResourceMapping("images", "6c4ae06e14bd422e97afe07223c99e18",
                            REMOTE_PROJECT_ID, "remote1"))

        EXPECTED = 'WEOFIHJREINJEFDOWEIJFWIENFERINWFKEWF'
        self.requests_fixture.get(
            'http://images.remote1/v2/images/'
            '6c4ae06e-14bd-422e-97af-e07223c99e18',
            text=six.u(EXPECTED),
            request_headers={'X-AUTH-TOKEN': REMOTE_TOKEN},
            headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(
            '/image/v2/images/6c4ae06e-14bd-422e-97af-e07223c99e18',
            headers={
                'X-AUTH-TOKEN': LOCAL_TOKEN,
                'CONTENT-TYPE': 'application/json'
            })
        self.assertEqual(response.data, six.b(EXPECTED))
Esempio n. 2
0
 def info(self, ctxt, publisher_id, event_type, payload, metadata):
     LOG.info('Creating snapshot mapping %s -> %s at %s' % (
              payload['snapshot_id'],
              payload['tenant_id'],
              self.sp_name))
     insert(ResourceMapping("snapshots",
            payload['snapshot_id'],
            payload['tenant_id'],
            self.sp_name))
Esempio n. 3
0
 def info(self, ctxt, publisher_id, event_type, payload, metadata):
     LOG.info('Creating image mapping %s -> %s at %s' % (
              payload['id'],
              payload['owner'],
              self.sp_name))
     insert(ResourceMapping("images",
            payload['id'],
            payload['owner'],
            self.sp_name))
Esempio n. 4
0
    def test_get_volume_remote_mapping(self):
        volume_id = uuid.uuid4().hex

        insert(
            ResourceMapping('volumes', volume_id,
                            self.remote_auth.get_project_id(), "remote1"))

        self.requests_fixture.get(
            self._construct_url(self.remote_auth, volume_id, sp='remote1'),
            text=volume_id,
            request_headers=self.remote_auth.get_headers(),
            headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(self._construct_url(self.remote_auth,
                                                    volume_id),
                                headers=self.auth.get_headers())
        self.assertEqual(response.get_data(as_text=True), volume_id)
Esempio n. 5
0
    def test_get_image_local(self):
        image_id = uuid.uuid4().hex
        image_data = uuid.uuid4().hex
        insert(
            ResourceMapping("images", image_id, self.auth.get_project_id(),
                            "default"))

        self.requests_fixture.get(self._construct_url(image_id=image_id,
                                                      sp='default'),
                                  text=image_data,
                                  request_headers=self.auth.get_headers(),
                                  headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(self._construct_url(image_id),
                                headers=self.auth.get_headers())

        self.assertEqual(response.get_data(as_text=True), image_data)
Esempio n. 6
0
    def test_get_image(self):
        self.session_fixture.add_local_auth('wewef', 'my_project_id')
        insert(ResourceMapping("images", "6c4ae06e14bd422e97afe07223c99e18",
                               "not-to-be-read", "default"))

        EXPECTED = 'WEOFIHJREINJEFDOWEIJFWIENFERINWFKEWF'
        self.requests_fixture.get(
            'http://images.local/v2/images/'
            '6c4ae06e-14bd-422e-97af-e07223c99e18',
            request_headers={'X-AUTH-TOKEN': 'wewef'},
            text=six.u(EXPECTED),
            headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(
            '/image/v2/images/6c4ae06e-14bd-422e-97af-e07223c99e18',
            headers={'X-AUTH-TOKEN': 'wewef',
                     'CONTENT-TYPE': 'application/json'})
        self.assertEqual(response.data, six.b(EXPECTED))
Esempio n. 7
0
    def test_get_image(self):
        self.session_fixture.add_local_auth('wewef', 'my_project_id')
        insert(
            ResourceMapping("images", "6c4ae06e14bd422e97afe07223c99e18",
                            "not-to-be-read", "default"))

        EXPECTED = 'WEOFIHJREINJEFDOWEIJFWIENFERINWFKEWF'
        self.requests_fixture.get(
            'http://images.local/v2/images/'
            '6c4ae06e-14bd-422e-97af-e07223c99e18',
            request_headers={'X-AUTH-TOKEN': 'wewef'},
            text=six.u(EXPECTED),
            headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(
            '/image/v2/images/6c4ae06e-14bd-422e-97af-e07223c99e18',
            headers={
                'X-AUTH-TOKEN': 'wewef',
                'CONTENT-TYPE': 'application/json'
            })
        self.assertEqual(response.data, six.b(EXPECTED))
Esempio n. 8
0
    def test_get_image_remote(self):
        REMOTE_PROJECT_ID = "319d8162b38342609f5fafe1404216b9"
        LOCAL_TOKEN = "my-local-token"
        REMOTE_TOKEN = "my-remote-token"

        self.session_fixture.add_sp_auth('remote1', LOCAL_TOKEN,
                                         REMOTE_PROJECT_ID, REMOTE_TOKEN)
        insert(ResourceMapping("images", "6c4ae06e14bd422e97afe07223c99e18",
                               REMOTE_PROJECT_ID, "remote1"))

        EXPECTED = 'WEOFIHJREINJEFDOWEIJFWIENFERINWFKEWF'
        self.requests_fixture.get(
            'http://images.remote1/v2/images/'
            '6c4ae06e-14bd-422e-97af-e07223c99e18',
            text=six.u(EXPECTED),
            request_headers={'X-AUTH-TOKEN': REMOTE_TOKEN},
            headers={'CONTENT-TYPE': 'application/json'})
        response = self.app.get(
            '/image/v2/images/6c4ae06e-14bd-422e-97af-e07223c99e18',
            headers={'X-AUTH-TOKEN': LOCAL_TOKEN,
                     'CONTENT-TYPE': 'application/json'})
        self.assertEqual(response.data, six.b(EXPECTED))
Esempio n. 9
0
 def info(self, ctxt, publisher_id, event_type, payload, metadata):
     LOG.info('Creating snapshot mapping %s -> %s at %s' %
              (payload['snapshot_id'], payload['tenant_id'], self.sp_name))
     insert(
         ResourceMapping("snapshots", payload['snapshot_id'],
                         payload['tenant_id'], self.sp_name))
Esempio n. 10
0
 def info(self, ctxt, publisher_id, event_type, payload, metadata):
     LOG.info('Creating image mapping %s -> %s at %s' %
              (payload['id'], payload['owner'], self.sp_name))
     insert(
         ResourceMapping("images", payload['id'], payload['owner'],
                         self.sp_name))