Exemplo n.º 1
0
    def test_that_client_cert_gets_downloaded(self):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        with HTTMock(ca_cert_mock, not_found_mock):
            smtp._download_client_certificates()

            path = self._client_cert_path()
            self.assertTrue(os.path.isfile(path))
Exemplo n.º 2
0
    def test_that_client_cert_gets_downloaded(self):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        with HTTMock(ca_cert_mock, not_found_mock):
            smtp._download_client_certificates()

            path = self._client_cert_path()
            self.assertTrue(os.path.isfile(path))
Exemplo n.º 3
0
    def test_that_start_calls_setup_smtp_gateway(self, gateway_mock):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)
        port = 500
        smtp.TWISTED_PORT = port
        gateway_mock.return_value = (None, None)
        with HTTMock(ca_cert_mock, not_found_mock):
            smtp.start()

        cert_path = self._client_cert_path()
        gateway_mock.assert_called_with(keymanager=self.keymanager, smtp_cert=cert_path, smtp_key=cert_path, userid='*****@*****.**', smtp_port='1234', encrypted_only=False, smtp_host='smtp.some-sever.test', port=port)
Exemplo n.º 4
0
    def test_that_start_calls_setup_smtp_gateway(self, gateway_mock):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)
        port = 500
        smtp.TWISTED_PORT = port
        gateway_mock.return_value = (None, None)
        with HTTMock(ca_cert_mock, not_found_mock):
            smtp.ensure_running()

        cert_path = self._client_cert_path()
        gateway_mock.assert_called_with(keymanager=self.keymanager, smtp_cert=cert_path, smtp_key=cert_path, userid='*****@*****.**', smtp_port='1234', encrypted_only=False, smtp_host='smtp.some-sever.test', port=port)
Exemplo n.º 5
0
    def test_that_running_smtp_sevice_is_stopped(self, gateway_mock):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        smtp_service = MagicMock()
        smtp_port = MagicMock()
        gateway_mock.return_value = (smtp_service, smtp_port)

        with HTTMock(ca_cert_mock, not_found_mock):
            smtp.start()
            smtp.stop()

        smtp_port.stopListening.assert_called_with()
        smtp_service.doStop.assert_called_with()
Exemplo n.º 6
0
    def test_that_start_calls_setup_smtp_gateway(self, gateway_mock):
        smtp = LeapSmtp(self.provider, self.auth, self.keymanager)

        port = 500
        smtp.local_smtp_port_number = port
        gateway_mock.return_value = (None, None)
        with HTTMock(ca_cert_mock, not_found_mock):
            smtp.ensure_running()

        cert_path = self._client_cert_path()
        gateway_mock.assert_called_with(
            keymanager=self.keymanager,
            smtp_cert=cert_path,
            smtp_key=cert_path,
            userid="*****@*****.**",
            smtp_port="1234",
            encrypted_only=False,
            smtp_host="smtp.some-sever.test",
            port=port,
        )
Exemplo n.º 7
0
    def test_that_running_smtp_sevice_is_stopped(self, gateway_mock):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        smtp_service = MagicMock()
        smtp_port = MagicMock()
        gateway_mock.return_value = (smtp_service, smtp_port)

        with HTTMock(ca_cert_mock, not_found_mock):
            smtp.ensure_running()
            smtp.stop()

        smtp_port.stopListening.assert_called_with()
        smtp_service.doStop.assert_called_with()
Exemplo n.º 8
0
    def test_that_client_stop_does_nothing_if_not_started(self):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        with HTTMock(not_found_mock):
            smtp.stop()
Exemplo n.º 9
0
    def test_that_client_stop_does_nothing_if_not_started(self):
        smtp = LeapSmtp(self.provider, self.auth.username,
                        self.auth.session_id, self.keymanager)

        with HTTMock(not_found_mock):
            smtp.stop()
Exemplo n.º 10
0
 def _create_smtp_server(self):
     server = LeapSmtp(self.leap_session.provider, self.leap_session.nicknym.keymanager, self.leap_session.srp_session)
     server.start()
     return server
Exemplo n.º 11
0
    def test_that_client_stop_does_nothing_if_not_started(self):
        smtp = LeapSmtp(self.provider, self.keymanager, self.srp_session)

        with HTTMock(not_found_mock):
            smtp.stop()