Esempio n. 1
0
 def do_and_report(reporter, communicator, node, pk12):
     qdevice_net.remote_client_import_certificate_and_key(
         communicator, node, pk12
     )
     reporter.process(
         reports.qdevice_certificate_accepted_by_node(node.label)
     )
    def test_success(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        node = "node address"
        pk12_cert = "pk12 certificate".encode("utf-8")

        lib.remote_client_import_certificate_and_key(mock_communicator, node,
                                                     pk12_cert)

        mock_communicator.call_node.assert_called_once_with(
            node, "remote/qdevice_net_client_import_certificate",
            "certificate={0}".format(cert_to_url(pk12_cert)))
    def test_success(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        node = "node address"
        pk12_cert = "pk12 certificate".encode("utf-8")

        lib.remote_client_import_certificate_and_key(
            mock_communicator,
            node,
            pk12_cert
        )

        mock_communicator.call_node.assert_called_once_with(
            node,
            "remote/qdevice_net_client_import_certificate",
            "certificate={0}".format(
                cert_to_url(pk12_cert)
            )
        )
    def test_comunication_error(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        mock_communicator.call_node.side_effect = NodeCommunicationException(
            "node address", "command", "reason")

        self.assertRaises(
            NodeCommunicationException,
            lambda: lib.remote_client_import_certificate_and_key(
                mock_communicator, "node address", "pk12 cert".encode("utf-8")
            ))
    def test_comunication_error(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        mock_communicator.call_node.side_effect = NodeCommunicationException(
            "node address", "command", "reason"
        )

        self.assertRaises(
            NodeCommunicationException,
            lambda: lib.remote_client_import_certificate_and_key(
                mock_communicator,
                "node address",
                "pk12 cert".encode("utf-8")
            )
        )
Esempio n. 6
0
 def do_and_report(reporter, communicator, node, pk12):
     qdevice_net.remote_client_import_certificate_and_key(
         communicator, node, pk12)
     reporter.process(
         reports.qdevice_certificate_accepted_by_node(node.label))