Exemplo n.º 1
0
def main():
    v_cassandra_storage = cassandra_storage.CassandraSanInfoStorage(CONF)

    sni_attribute_default_list = {
        'enrollmentId': None,
    }

    sni_info_dict = dict()

    for sni_cert_name in CONF[driver.AKAMAI_GROUP].sni_cert_cnames:
        sni_info_dict[sni_cert_name] = {}
        print("Insert SNI info for: {0}".format(sni_cert_name))
        for attr in sni_attribute_default_list:
            user_input = None
            while ((user_input or "").strip() or user_input) in ["", None]:
                user_input = input(
                    'Please input value for attr: {0}, SNI cert: {1}, '
                    'default value: {2} (if default is None, '
                    'that means a real value has to be input): '.format(
                        attr, sni_cert_name, sni_attribute_default_list[attr]))
                # enrollmentId is required
                if user_input in ["", None] and attr == "enrollmentId":
                    break
                if sni_attribute_default_list[attr] is None:
                    continue
                else:
                    user_input = sni_attribute_default_list[attr]
                    break
            sni_info_dict[sni_cert_name][attr] = user_input

    v_cassandra_storage.update_san_info(sni_info_dict, info_type='sni')
Exemplo n.º 2
0
 def test__get_akamai_provider_info(self):
     self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
         self.conf)
     mock_execute = self.cassandra_storage.session.execute
     mock_execute.return_value = self.get_returned_value
     res = self.cassandra_storage._get_akamai_provider_info()
     mock_execute.assert_called()
     self.assertTrue(res == self.get_returned_value[0])
Exemplo n.º 3
0
    def test_save_cert_last_spsid(self, san_cert_name):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value

        self.cassandra_storage.save_cert_last_ids(san_cert_name, '1234')
        self.assertTrue(mock_execute.call_count == 3)
Exemplo n.º 4
0
    def test_usage_non_shared_cassandra_cluster(self):
        with mock.patch('poppy.storage.cassandra.driver.CassandraStorageDriver'
                        ) as mock_driver:
            mock_d = mock.Mock()
            mock_d.cassandra_conf.consistency_level = 'ONE'
            mock_driver.return_value = mock_d
            cass = cassandra_storage.CassandraSanInfoStorage(self.conf)

        self.assertTrue(cass.storage.change_config_group.called)
Exemplo n.º 5
0
    def test_list_all_san_cert_names(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value

        res = self.cassandra_storage.list_all_san_cert_names()
        mock_execute.assert_called()
        self.assertTrue(res == json.loads(self.get_returned_value[0]['info']
                                          ['san_info']).keys())
Exemplo n.º 6
0
    def test_set_san_cert_hostname_limit(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf
        )

        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value

        self.cassandra_storage.set_san_cert_hostname_limit(99)

        mock_execute.assert_called()
Exemplo n.º 7
0
    def test__get_akamai_sni_certs_info(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value

        res = self.cassandra_storage._get_akamai_sni_certs_info()
        mock_execute.assert_called()
        self.assertTrue(
            res == json.loads(self.get_returned_value[0]['info']['sni_info'])
        )
Exemplo n.º 8
0
    def test_update_cert_config(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value
        cert_name = "secure1.san1.test-cdn.com"
        new_spsId = 3456

        self.cassandra_storage.update_cert_config(cert_name,
                                                  {'spsId': new_spsId})
        mock_execute.assert_called()
Exemplo n.º 9
0
    def test_get_cert_last_spsid(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value
        cert_name = "secure1.san1.test-cdn.com"

        res = self.cassandra_storage.get_cert_last_spsid(cert_name)
        mock_execute.assert_called()
        self.assertTrue(res == json.loads(self.get_returned_value[0]['info']
                                          ['san_info'])[cert_name]['spsId'])
Exemplo n.º 10
0
    def test_get_san_cert_hostname_limit(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf
        )

        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value

        res = self.cassandra_storage.get_san_cert_hostname_limit()

        mock_execute.assert_called()
        self.assertEqual(res, self.default_limit)
Exemplo n.º 11
0
    def test_update_sni_cert_config(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value
        cert_name = "secured2.sni1.test-cdn.com"
        new_enrollment_id = 9898

        self.cassandra_storage.update_sni_cert_config(
            cert_name, {'enrollmentId': new_enrollment_id}
        )
        mock_execute.assert_called()
Exemplo n.º 12
0
def main():
    v_cassandra_storage = cassandra_storage.CassandraSanInfoStorage(CONF)

    all_san_cert_names = v_cassandra_storage.list_all_san_cert_names()

    if not all_san_cert_names:
        print("Currently no SAN cert info has been initialized")

    for san_cert_name in all_san_cert_names:
        print("%s:%s" %
              (san_cert_name,
               str(v_cassandra_storage.get_cert_info(san_cert_name))))
Exemplo n.º 13
0
    def test_get_sni_cert_info(self):
        self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
            self.conf)
        mock_execute = self.cassandra_storage.session.execute
        mock_execute.return_value = self.get_returned_value
        cert_name = "secured2.sni1.test-cdn.com"

        res = self.cassandra_storage.get_sni_cert_info(
            cert_name
        )
        mock_execute.assert_called()
        self.assertTrue(
            res['enrollmentId'] == str(json.loads(
                self.get_returned_value[0]['info']['sni_info']
                )[cert_name]['enrollmentId'])
        )
Exemplo n.º 14
0
def main():
    v_cassandra_storage = cassandra_storage.CassandraSanInfoStorage(CONF)

    sni_attribute_default_list = {
        'enrollmentId': None,
    }

    sni_info_dict = dict()
    cnames = CONF[driver.AKAMAI_GROUP].sni_cert_cnames
    enrollment_ids = CONF[driver.AKAMAI_GROUP].sni_cert_enrollment_ids

    if enrollment_ids and len(cnames) == len(enrollment_ids):
        print("Found valid 'sni_cert_enrollment_ids' setting in poppy.conf")
        print("{:-^50}\n".format(" Starting upsert "))

        for cname, eid in zip(cnames, enrollment_ids):
            sni_info_dict[cname] = {}
            sni_info_dict[cname]["enrollmentId"] = eid

            print("{} -> {}".format(cname, eid))
        print("\n{:-^50}".format(" Finished "))
    else:
        for sni_cert_name in cnames:
            sni_info_dict[sni_cert_name] = {}
            print("Insert SNI info for: {0}".format(sni_cert_name))
            for attr in sni_attribute_default_list:
                user_input = None
                while ((user_input or "").strip() or user_input) in ["", None]:
                    user_input = input(
                        'Please input value for attr: {0}, SNI cert: {1}, '
                        'default value: {2} (if default is None, '
                        'that means a real value has to be input): '.format(
                            attr, sni_cert_name,
                            sni_attribute_default_list[attr]))
                    # enrollmentId is required
                    if user_input in ["", None] and attr == "enrollmentId":
                        break
                    if sni_attribute_default_list[attr] is None:
                        continue
                    else:
                        user_input = sni_attribute_default_list[attr]
                        break
                sni_info_dict[sni_cert_name][attr] = user_input

    v_cassandra_storage.update_san_info(sni_info_dict, info_type='sni')
Exemplo n.º 15
0
def main():
    v_cassandra_storage = cassandra_storage.CassandraSanInfoStorage(CONF)

    san_attribute_default_list = {
        'issuer': 'symantec',
        'ipVersion': 'ipv4',
        'slot_deployment_klass': 'esslType',
        'spsId': None,
        'jobId': None
    }

    san_info_dict = {}
    for san_cert_name in CONF[driver.AKAMAI_GROUP].san_cert_cnames:
        san_info_dict[san_cert_name] = {}
        print("Insert SAN info for :%s" % (san_cert_name))
        for attr in san_attribute_default_list:
            user_input = None
            while ((user_input or "").strip() or user_input) in ["", None]:
                user_input = raw_input(
                    'Please input value for attr: %s, '
                    'San cert: %s,'
                    'default value: %s'
                    ' (if default is None, '
                    'that means a real value has to'
                    ' be input, except spsId): ' %
                    (attr, san_cert_name, san_attribute_default_list[attr]))
                # We allow not inputing spsId, however if it is in
                # transitioning from the old manual SAN process we NEED
                # to put in spsId
                if user_input in ["", None] and attr == "spsId":
                    break
                if san_attribute_default_list[attr] is None:
                    continue
                else:
                    user_input = san_attribute_default_list[attr]
                    break
            san_info_dict[san_cert_name][attr] = user_input

    v_cassandra_storage.update_san_info(san_info_dict)
Exemplo n.º 16
0
 def test_update_san_info(self):
     self.cassandra_storage = cassandra_storage.CassandraSanInfoStorage(
         self.conf)
     mock_execute = self.cassandra_storage.session.execute
     self.cassandra_storage.update_san_info({})
     mock_execute.assert_called()