示例#1
0
 def test_ec2_get_credential(self):
     ec2_cred = self._get_ec2_cred()
     uri = '/'.join([self._get_ec2_cred_uri(), ec2_cred['access']])
     r = self.get(uri)
     self.assertDictEqual(ec2_cred, r.result['credential'])
     self.assertThat(ec2_cred['links']['self'],
                     matchers.EndsWith(uri))
示例#2
0
 def test_ec2_list_credentials(self):
     """Test ec2 credential listing."""
     self._get_ec2_cred()
     uri = self._get_ec2_cred_uri()
     r = self.get(uri)
     cred_list = r.result['credentials']
     self.assertEqual(1, len(cred_list))
     self.assertThat(r.result['links']['self'], matchers.EndsWith(uri))
示例#3
0
    def test_volume_with_image_metadata(self):
        v = self.stub_volume(id='1234', volume_image_metadata=_image_metadata)
        m = self.requests.get(self.URL + '/volumes/5678', json={'volume': v})

        volume = self.api.get(self.context, '5678')
        self.assertThat(m.last_request.path,
                        matchers.EndsWith('/volumes/5678'))
        self.assertIn('volume_image_metadata', volume)
        self.assertEqual(volume['volume_image_metadata'], _image_metadata)
示例#4
0
 def test_ec2_create_credential(self):
     """Test ec2 credential creation."""
     ec2_cred = self._get_ec2_cred()
     self.assertEqual(self.user_id, ec2_cred['user_id'])
     self.assertEqual(self.project_id, ec2_cred['tenant_id'])
     self.assertIsNone(ec2_cred['trust_id'])
     self._validate_signature(access=ec2_cred['access'],
                              secret=ec2_cred['secret'])
     uri = '/'.join([self._get_ec2_cred_uri(), ec2_cred['access']])
     self.assertThat(ec2_cred['links']['self'], matchers.EndsWith(uri))
示例#5
0
 def test_template(self):
     files = ['specs/template.rst'] + glob.glob('specs/*/*')
     for filename in files:
         self.assertThat(filename, matchers.EndsWith('.rst'),
                         'spec\'s file must use the "rst" extension.')
         with open(filename) as f:
             data = f.read()
         spec = docutils.core.publish_doctree(data)
         titles = self._get_titles(spec)
         self._check_titles(titles)
    def test_volume_with_image_metadata(self):
        v = self.stub_volume(id='1234', volume_image_metadata=_image_metadata)
        try:
            m = self.requests.get(self.URL + '/volumes/5678', json={'volume': v})
        except:
            self.skipTest('Skipped by Ubuntu')

        volume = self.api.get(self.context, '5678')
        self.assertThat(m.last_request.path,
                        matchers.EndsWith('/volumes/5678'))
        self.assertIn('volume_image_metadata', volume)
        self.assertEqual(_image_metadata, volume['volume_image_metadata'])
示例#7
0
    def assertValidListLinks(self, links, resource_url=None):
        self.assertIsNotNone(links)
        self.assertIsNotNone(links.get('self'))
        self.assertThat(links['self'], matchers.StartsWith('http://localhost'))

        if resource_url:
            self.assertThat(links['self'], matchers.EndsWith(resource_url))

        self.assertIn('next', links)
        if links['next'] is not None:
            self.assertThat(links['next'],
                            matchers.StartsWith('http://localhost'))

        self.assertIn('previous', links)
        if links['previous'] is not None:
            self.assertThat(links['previous'],
                            matchers.StartsWith('http://localhost'))
示例#8
0
    def test_ec2_list_credentials(self):
        """Test ec2 credential listing."""
        self._get_ec2_cred()
        uri = self._get_ec2_cred_uri()
        r = self.get(uri)
        cred_list = r.result['credentials']
        self.assertEqual(1, len(cred_list))
        self.assertThat(r.result['links']['self'], matchers.EndsWith(uri))

        # non-EC2 credentials won't be fetched
        non_ec2_cred = unit.new_credential_ref(user_id=self.user_id,
                                               project_id=self.project_id)
        non_ec2_cred['type'] = uuid.uuid4().hex
        self.credential_api.create_credential(non_ec2_cred['id'], non_ec2_cred)
        r = self.get(uri)
        cred_list_2 = r.result['credentials']
        # still one element because non-EC2 credentials are not returned.
        self.assertEqual(1, len(cred_list_2))
        self.assertEqual(cred_list[0], cred_list_2[0])
示例#9
0
    def test_create_endpoint_group(self):
        """POST /OS-EP-FILTER/endpoint_groups

        Valid endpoint group test case.

        """
        r = self.post(self.DEFAULT_ENDPOINT_GROUP_URL,
                      body=self.DEFAULT_ENDPOINT_GROUP_BODY)
        expected_filters = (
            self.DEFAULT_ENDPOINT_GROUP_BODY['endpoint_group']['filters'])
        expected_name = (
            self.DEFAULT_ENDPOINT_GROUP_BODY['endpoint_group']['name'])
        self.assertEqual(expected_filters,
                         r.result['endpoint_group']['filters'])
        self.assertEqual(expected_name, r.result['endpoint_group']['name'])
        self.assertThat(
            r.result['endpoint_group']['links']['self'],
            matchers.EndsWith(
                '/OS-EP-FILTER/endpoint_groups/%(endpoint_group_id)s' %
                {'endpoint_group_id': r.result['endpoint_group']['id']}))
示例#10
0
    def test_patch_endpoint_group(self):
        """PATCH /OS-EP-FILTER/endpoint_groups/{endpoint_group}

        Valid endpoint group patch test case.

        """
        body = copy.deepcopy(self.DEFAULT_ENDPOINT_GROUP_BODY)
        body['endpoint_group']['filters'] = {'region_id': 'UK'}
        body['endpoint_group']['name'] = 'patch_test'
        # create an endpoint group to work with
        endpoint_group_id = self._create_valid_endpoint_group(
            self.DEFAULT_ENDPOINT_GROUP_URL, self.DEFAULT_ENDPOINT_GROUP_BODY)
        url = '/OS-EP-FILTER/endpoint_groups/%(endpoint_group_id)s' % {
            'endpoint_group_id': endpoint_group_id
        }
        r = self.patch(url, body=body)
        self.assertEqual(endpoint_group_id, r.result['endpoint_group']['id'])
        self.assertEqual(body['endpoint_group']['filters'],
                         r.result['endpoint_group']['filters'])
        self.assertThat(r.result['endpoint_group']['links']['self'],
                        matchers.EndsWith(url))
示例#11
0
    def test_command_hooks(self):
        """Test command hooks.

        Simple test that the appropriate command hooks run at the
        beginning/end of the appropriate command.
        """

        stdout, _, return_code = self.run_setup('egg_info')
        assert 'build_ext pre-hook' not in stdout
        assert 'build_ext post-hook' not in stdout
        assert return_code == 0

        stdout, stderr, return_code = self.run_setup('build_ext')
        self.addDetailUniqueName('stderr', content.text_content(stderr))
        assert textwrap.dedent("""
            running build_ext
            running pre_hook pbr_testpackage._setup_hooks.test_pre_hook for command build_ext
            build_ext pre-hook
        """) in stdout  # flake8: noqa
        self.expectThat(stdout, matchers.EndsWith('build_ext post-hook'))
        assert return_code == 0
示例#12
0
    def test_get_endpoint_group(self):
        """GET /OS-EP-FILTER/endpoint_groups/{endpoint_group}

        Valid endpoint group test case.

        """
        # create an endpoint group to work with
        response = self.post(self.DEFAULT_ENDPOINT_GROUP_URL,
                             body=self.DEFAULT_ENDPOINT_GROUP_BODY)
        endpoint_group_id = response.result['endpoint_group']['id']
        endpoint_group_filters = response.result['endpoint_group']['filters']
        endpoint_group_name = response.result['endpoint_group']['name']
        url = '/OS-EP-FILTER/endpoint_groups/%(endpoint_group_id)s' % {
            'endpoint_group_id': endpoint_group_id}
        self.get(url)
        self.assertEqual(endpoint_group_id,
                         response.result['endpoint_group']['id'])
        self.assertEqual(endpoint_group_filters,
                         response.result['endpoint_group']['filters'])
        self.assertEqual(endpoint_group_name,
                         response.result['endpoint_group']['name'])
        self.assertThat(response.result['endpoint_group']['links']['self'],
                        matchers.EndsWith(url))
示例#13
0
 def test_revoked_list_self_url(self):
     revoked_list_url = '/OS-REVOKE/events'
     resp = self.get(revoked_list_url)
     links = resp.json_body['links']
     self.assertThat(links['self'], matchers.EndsWith(revoked_list_url))