Exemple #1
0
    def test_certificate_sign_and_show(self):
        first_model = datagen.valid_bay_data(baymodel_id=self.baymodel.uuid,
                                             name='test')
        _, bay_model = self._create_bay(first_model)

        # test ca show
        resp, model = self.cert_client.get_cert(
            bay_model.uuid)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(model.bay_uuid, bay_model.uuid)
        self.assertIsNotNone(model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', model.pem)
        self.assertIn('-----END CERTIFICATE-----', model.pem)

        # test ca sign
        model = datagen.cert_data(bay_uuid=bay_model.uuid)
        resp, model = self.cert_client.post_cert(model)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(model.bay_uuid, bay_model.uuid)
        self.assertIsNotNone(model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', model.pem)
        self.assertIn('-----END CERTIFICATE-----', model.pem)

        # test ca sign invalid
        model = datagen.cert_data(bay_uuid=bay_model.uuid,
                                  csr_data="invalid_csr")
        self.assertRaises(
            exceptions.BadRequest,
            self.cert_client.post_cert,
            model)
Exemple #2
0
    def test_certificate_sign_and_show(self):
        first_model = datagen.valid_bay_data(baymodel_id=self.baymodel.uuid,
                                             name='test')
        _, bay_model = self._create_bay(first_model)

        # test ca show
        resp, model = self.cert_client.get_cert(bay_model.uuid)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(model.bay_uuid, bay_model.uuid)
        self.assertIsNotNone(model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', model.pem)
        self.assertIn('-----END CERTIFICATE-----', model.pem)

        # test ca sign
        model = datagen.cert_data(bay_uuid=bay_model.uuid)
        resp, model = self.cert_client.post_cert(model)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(model.bay_uuid, bay_model.uuid)
        self.assertIsNotNone(model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', model.pem)
        self.assertIn('-----END CERTIFICATE-----', model.pem)

        # test ca sign invalid
        model = datagen.cert_data(bay_uuid=bay_model.uuid,
                                  csr_data="invalid_csr")
        self.assertRaises(exceptions.BadRequest, self.cert_client.post_cert,
                          model)
Exemple #3
0
    def test_create_list_sign_delete_clusters(self):
        gen_model = datagen.valid_cluster_data(
            cluster_template_id=self.cluster_template.uuid, node_count=1)

        # test cluster create
        _, cluster_model = self._create_cluster(gen_model)
        self.assertNotIn('status', cluster_model)

        # test cluster list
        resp, cluster_list_model = self.cluster_client.list_clusters()
        self.assertEqual(200, resp.status)
        self.assertGreater(len(cluster_list_model.clusters), 0)
        self.assertIn(
            cluster_model.uuid, list([x['uuid']
                                      for x in cluster_list_model.clusters]))

        # test invalid cluster update
        patch_model = datagen.cluster_name_patch_data()
        self.assertRaises(
            exceptions.BadRequest,
            self.cluster_client.patch_cluster,
            cluster_model.uuid, patch_model)

        # test ca show
        resp, cert_model = self.cert_client.get_cert(
            cluster_model.uuid)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(cert_model.bay_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign
        cert_data_model = datagen.cert_data(cluster_model.uuid)
        resp, cert_model = self.cert_client.post_cert(cert_data_model)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(cert_model.bay_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign invalid
        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data="invalid_csr")
        self.assertRaises(
            exceptions.BadRequest,
            self.cert_client.post_cert,
            cert_data_model)

        # test cluster delete
        self._delete_cluster(cluster_model.uuid)
        self.clusters.remove(cluster_model.uuid)
Exemple #4
0
    def test_create_list_sign_delete_clusters(self):
        gen_model = datagen.valid_cluster_data(
            cluster_template_id=self.cluster_template.uuid, node_count=1)

        # test cluster create
        _, cluster_model = self._create_cluster(gen_model)
        self.assertNotIn('status', cluster_model)

        # test cluster list
        resp, cluster_list_model = self.cluster_client.list_clusters()
        self.assertEqual(200, resp.status)
        self.assertGreater(len(cluster_list_model.clusters), 0)
        self.assertIn(cluster_model.uuid,
                      list([x['uuid'] for x in cluster_list_model.clusters]))

        # test invalid cluster update
        patch_model = datagen.cluster_name_patch_data()
        self.assertRaises(exceptions.BadRequest,
                          self.cluster_client.patch_cluster,
                          cluster_model.uuid, patch_model)

        # test ca show
        resp, cert_model = self.cert_client.get_cert(cluster_model.uuid)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(cert_model.bay_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign
        cert_data_model = datagen.cert_data(cluster_model.uuid)
        resp, cert_model = self.cert_client.post_cert(cert_data_model)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(cert_model.bay_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign invalid
        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data="invalid_csr")
        self.assertRaises(exceptions.BadRequest, self.cert_client.post_cert,
                          cert_data_model)

        # test cluster delete
        self._delete_cluster(cluster_model.uuid)
        self.clusters.remove(cluster_model.uuid)
Exemple #5
0
    def test_create_list_sign_delete_clusters(self):
        gen_model = datagen.valid_cluster_data(
            cluster_template_id=self.cluster_template.uuid, node_count=1)

        # test cluster create
        _, cluster_model = self._create_cluster(gen_model)
        self.assertNotIn('status', cluster_model)

        # test cluster list
        resp, cluster_list_model = self.cluster_client.list_clusters()
        self.assertEqual(200, resp.status)
        self.assertGreater(len(cluster_list_model.clusters), 0)
        self.assertIn(cluster_model.uuid,
                      list([x['uuid'] for x in cluster_list_model.clusters]))

        # test invalid cluster update
        patch_model = datagen.cluster_name_patch_data()
        self.assertRaises(exceptions.BadRequest,
                          self.cluster_client.patch_cluster,
                          cluster_model.uuid, patch_model)

        # test ca show
        resp, cert_model = self.cert_client.get_cert(cluster_model.uuid)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign

        csr_sample = """-----BEGIN CERTIFICATE REQUEST-----
MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w
HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v
Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV
IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr
WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J
cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl
4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH
Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn
-----END CERTIFICATE REQUEST-----
"""

        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data=csr_sample)
        resp, cert_model = self.cert_client.post_cert(cert_data_model)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign invalid
        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data="invalid_csr")
        self.assertRaises(exceptions.BadRequest, self.cert_client.post_cert,
                          cert_data_model)

        # test cluster delete
        self._delete_cluster(cluster_model.uuid)
        self.clusters.remove(cluster_model.uuid)
Exemple #6
0
    def test_create_list_sign_delete_clusters(self):
        gen_model = datagen.valid_cluster_data(
            cluster_template_id=self.cluster_template.uuid, node_count=1)

        # test cluster create
        _, cluster_model = self._create_cluster(gen_model)
        self.assertNotIn('status', cluster_model)

        # test cluster list
        resp, cluster_list_model = self.cluster_client.list_clusters()
        self.assertEqual(200, resp.status)
        self.assertGreater(len(cluster_list_model.clusters), 0)
        self.assertIn(
            cluster_model.uuid, list([x['uuid']
                                      for x in cluster_list_model.clusters]))

        # test invalid cluster update
        patch_model = datagen.cluster_name_patch_data()
        self.assertRaises(
            exceptions.BadRequest,
            self.cluster_client.patch_cluster,
            cluster_model.uuid, patch_model)

        # test ca show
        resp, cert_model = self.cert_client.get_cert(
            cluster_model.uuid, headers=HEADERS)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(200, resp.status)
        self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign

        csr_sample = """-----BEGIN CERTIFICATE REQUEST-----
MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w
HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v
Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV
IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr
WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J
cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl
4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH
Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn
-----END CERTIFICATE REQUEST-----
"""

        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data=csr_sample)
        resp, cert_model = self.cert_client.post_cert(cert_data_model,
                                                      headers=HEADERS)
        self.LOG.debug("cert resp: %s" % resp)
        self.assertEqual(201, resp.status)
        self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
        self.assertIsNotNone(cert_model.pem)
        self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
        self.assertIn('-----END CERTIFICATE-----', cert_model.pem)

        # test ca sign invalid
        cert_data_model = datagen.cert_data(cluster_model.uuid,
                                            csr_data="invalid_csr")
        self.assertRaises(
            exceptions.BadRequest,
            self.cert_client.post_cert,
            cert_data_model, headers=HEADERS)

        # test cluster delete
        self._delete_cluster(cluster_model.uuid)
        self.clusters.remove(cluster_model.uuid)