def test_add_session_ticket_success(self, requests, os_path): nginx = Nginx({'CA_CERT': 'cert data'}) os_path.exists.return_value = True response = mock.Mock() response.status_code = 200 response.text = '\n\nticket was succsessfully added' requests.request.return_value = response nginx.add_session_ticket('host-1', 'random data', timeout=2) requests.request.assert_called_once_with('post', 'https://host-1:8090/session_ticket', timeout=2, data='random data', verify='/tmp/rpaas_ca.pem')
def test_add_session_ticket_success(self, requests, os_path): nginx = Nginx({'CA_CERT': 'cert data'}) os_path.exists.return_value = True response = mock.Mock() response.status_code = 200 response.text = '\n\nticket was succsessfully added' requests.request.return_value = response nginx.add_session_ticket('host-1', 'random data', timeout=2) requests.request.assert_called_once_with( 'post', 'https://host-1:8090/session_ticket', timeout=2, data='random data', verify='/tmp/rpaas_ca.pem')
def test_missing_ca_cert(self, requests): nginx = Nginx() with self.assertRaises(NginxError): nginx.add_session_ticket('host-1', 'random data', timeout=2)