def test_create_server_cert_duplicate_ids_invalid(self): """ Test API create_server_cert raises exception when invalid validity day values used """ cert_util = EdgeCertUtil() cert_util.create_root_ca_cert('root', subject_dict=VALID_SUBJECT_DICT) with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('root', 'root', host_name='name')
def test_create_server_cert_validity_days_invalid(self): """ Test API create_server_cert raises exception when invalid validity day values used """ cert_util = EdgeCertUtil() cert_util.create_root_ca_cert('root', subject_dict=VALID_SUBJECT_DICT) for validity in [-1, 0, 366, 1096]: with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('server', 'root', host_name='name', validity_days_from_now=validity)
def test_create_server_cert_hostname_invalid(self): """ Test API create_server_cert raises exception when hostname is invalid """ cert_util = EdgeCertUtil() cert_util.create_root_ca_cert('root', subject_dict=VALID_SUBJECT_DICT) with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('int', 'root') with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('int', 'root', host_name=None) with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('int', 'root', host_name='') bad_hostname = 'a' * 65 with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('int', 'root', host_name=bad_hostname)
def test_create_server_cert_passphrase_invalid(self): """ Test API create_server_cert raises exception when passphrase is invalid """ cert_util = EdgeCertUtil() cert_util.create_root_ca_cert('root', subject_dict=VALID_SUBJECT_DICT) with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('server', 'root', host_name='name', passphrase='') with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('server', 'root', host_name='name', passphrase='123') bad_pass = '******' * 1024 with self.assertRaises(edgectl.errors.EdgeValueError): cert_util.create_server_cert('server', 'root', host_name='name', passphrase=bad_pass)