Пример #1
0
    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_test_x509keypair(self.context, id=id_,
                                              uuid=uuidutils.generate_uuid())
        response = self.get_json('/x509keypairs/?limit=3')
        self.assertEqual(3, len(response['x509keypairs']))

        next_marker = response['x509keypairs'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
Пример #2
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api')
        for id_ in range(5):
            obj_utils.create_test_x509keypair(self.context, id=id_,
                                              uuid=uuidutils.generate_uuid())
        response = self.get_json('/x509keypairs')
        self.assertEqual(3, len(response['x509keypairs']))

        next_marker = response['x509keypairs'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
Пример #3
0
 def test_links(self):
     uuid = uuidutils.generate_uuid()
     obj_utils.create_test_x509keypair(self.context, id=1, uuid=uuid)
     response = self.get_json('/x509keypairs/%s' % uuid)
     self.assertIn('links', response.keys())
     self.assertEqual(2, len(response['links']))
     self.assertIn(uuid, response['links'][0]['href'])
     for l in response['links']:
         bookmark = l['rel'] == 'bookmark'
         self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
Пример #4
0
 def test_get_one_by_name_multiple_x509keypair(self):
     obj_utils.create_test_x509keypair(self.context,
                                       name='test_x509keypair',
                                       uuid=uuidutils.generate_uuid())
     obj_utils.create_test_x509keypair(self.context,
                                       name='test_x509keypair',
                                       uuid=uuidutils.generate_uuid())
     response = self.get_json('/x509keypairs/test_x509keypair',
                              expect_errors=True)
     self.assertEqual(409, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['errors'])
Пример #5
0
 def test_delete_multiple_x509keypair_by_name(self):
     obj_utils.create_test_x509keypair(self.context,
                                       name='test_x509keypair',
                                       uuid=utils.generate_uuid())
     obj_utils.create_test_x509keypair(self.context,
                                       name='test_x509keypair',
                                       uuid=utils.generate_uuid())
     response = self.delete('/x509keypairs/test_x509keypair',
                            expect_errors=True)
     self.assertEqual(409, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
Пример #6
0
 def test_detail(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json('/x509keypairs/detail')
     self.assertEqual(x509keypair.uuid, response['x509keypairs'][0]["uuid"])
     self.assertIn('name', response['x509keypairs'][0])
     self.assertIn('bay_uuid', response['x509keypairs'][0])
     self.assertIn('certificate', response['x509keypairs'][0])
     self.assertIn('private_key', response['x509keypairs'][0])
Пример #7
0
 def test_get_one_by_name(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json('/x509keypairs/%s' % x509keypair['name'])
     self.assertEqual(x509keypair.uuid, response['uuid'])
     self.assertIn('name', response)
     self.assertIn('bay_uuid', response)
     self.assertIn('certificate', response)
     self.assertIn('private_key', response)
Пример #8
0
 def test_detail(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json('/x509keypairs/detail')
     self.assertEqual(x509keypair.uuid, response['x509keypairs'][0]["uuid"])
     self.assertIn('name', response['x509keypairs'][0])
     self.assertIn('bay_uuid', response['x509keypairs'][0])
     self.assertIn('certificate', response['x509keypairs'][0])
     self.assertIn('private_key', response['x509keypairs'][0])
Пример #9
0
 def test_get_one_by_name(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json('/x509keypairs/%s' % x509keypair['name'])
     self.assertEqual(x509keypair.uuid, response['uuid'])
     self.assertIn('name', response)
     self.assertIn('bay_uuid', response)
     self.assertIn('certificate', response)
     self.assertIn('private_key', response)
Пример #10
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.bay = obj_utils.create_test_bay(self.context)
     self.x509keypair = obj_utils.create_test_x509keypair(self.context)
     p = mock.patch.object(rpcapi.API, 'x509keypair_delete')
     self.mock_x509keypair_delete = p.start()
     self.mock_x509keypair_delete.side_effect = \
         self._simulate_rpc_x509keypair_delete
     self.addCleanup(p.stop)
Пример #11
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.bay = obj_utils.create_test_bay(self.context)
     self.x509keypair = obj_utils.create_test_x509keypair(self.context)
     p = mock.patch.object(rpcapi.API, 'x509keypair_delete')
     self.mock_x509keypair_delete = p.start()
     self.mock_x509keypair_delete.side_effect = \
         self._simulate_rpc_x509keypair_delete
     self.addCleanup(p.stop)
Пример #12
0
 def test_many(self):
     keypair_list = []
     for id_ in range(5):
         x509keypair = obj_utils.create_test_x509keypair(
             self.context, id=id_, uuid=utils.generate_uuid())
         keypair_list.append(x509keypair.uuid)
     response = self.get_json('/x509keypairs')
     self.assertEqual(len(keypair_list), len(response['x509keypairs']))
     uuids = [b['uuid'] for b in response['x509keypairs']]
     self.assertEqual(sorted(keypair_list), sorted(uuids))
Пример #13
0
 def test_many(self):
     keypair_list = []
     for id_ in range(5):
         x509keypair = obj_utils.create_test_x509keypair(
             self.context, id=id_,
             uuid=uuidutils.generate_uuid())
         keypair_list.append(x509keypair.uuid)
     response = self.get_json('/x509keypairs')
     self.assertEqual(len(keypair_list), len(response['x509keypairs']))
     uuids = [b['uuid'] for b in response['x509keypairs']]
     self.assertEqual(sorted(keypair_list), sorted(uuids))
Пример #14
0
 def test_detail_against_single(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json(
         '/x509keypairs/%s/detail' % x509keypair['uuid'],
         expect_errors=True)
     self.assertEqual(404, response.status_int)
Пример #15
0
 def test_detail_against_single(self):
     x509keypair = obj_utils.create_test_x509keypair(self.context)
     response = self.get_json('/x509keypairs/%s/detail' %
                              x509keypair['uuid'],
                              expect_errors=True)
     self.assertEqual(404, response.status_int)