def test_enroll_missing_enrollment_csr(self): """Test enroll missing enrollment csr. """ ca_client = CAClient("http://" + self._ca_server_address) with self.assertRaises(ValueError): ca_client.enroll(self._enrollment_id, self._enrollment_secret, "")
def test_enroll_unreachable_server_address(self): """Test enroll unreachable server address. """ self._ca_server_address = "test:80" ca_client = CAClient("http://" + self._ca_server_address) with self.assertRaises(Exception): ca_client.enroll(self._enrollment_id, self._enrollment_secret, test_pem)
def test_enroll_invalid_server_address(self): """Test enroll invalid server address. """ self._ca_server_address = "test:80:90" ca_client = CAClient("http://" + self._ca_server_address) with self.assertRaises(RequestException): ca_client.enroll(self._enrollment_id, self._enrollment_secret, test_pem)
def test_enroll_success(self): """Test enroll success. """ self.shutdown_test_env() self.start_test_env() time.sleep(5) ca_client = CAClient("http://" + self._ca_server_address) ecert = ca_client.enroll(self._enrollment_id, self._enrollment_secret, test_pem) self.assertTrue(ecert.startswith(b"-----BEGIN CERTIFICATE-----")) self.shutdown_test_env()