Example #1
0
    def test_cannot_read_file(self):
        cert_tool_output = dedent(
            """
            some line
            Certificate request stored in {0}.bad
            some other line
            """.format(
                self.file_path
            )
        )
        report_item_message = reports.messages.QdeviceCertificateImportError

        assert_raise_library_error(
            lambda: lib._get_output_certificate(
                cert_tool_output,
                report_item_message,
            ),
            (
                severity.ERROR,
                report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR,
                {
                    "reason": "{0}.bad: No such file or directory".format(
                        self.file_path
                    ),
                },
            ),
        )
Example #2
0
    def test_cannot_read_file(self):
        cert_tool_output = dedent(
            """
            some line
            Certificate request stored in {0}.bad
            some other line
            """.format(self.file_path)
        )
        report_func = reports.qdevice_certificate_import_error

        assert_raise_library_error(
            lambda: lib._get_output_certificate(
                cert_tool_output,
                report_func
            ),
            (
                severity.ERROR,
                report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR,
                {
                    "reason": "{0}.bad: No such file or directory".format(
                        self.file_path
                    ),
                }
            )
        )
Example #3
0
    def test_message_not_found(self):
        cert_tool_output = "some rubbish output"
        report_func = reports.qdevice_certificate_import_error

        assert_raise_library_error(
            lambda: lib._get_output_certificate(cert_tool_output, report_func),
            (severity.ERROR, report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR, {
                "reason": cert_tool_output,
            }))
Example #4
0
    def test_success_request(self):
        cert_tool_output = dedent("""
            some line
            Certificate request stored in {0}
            some other line
            """.format(self.file_path))
        report_func = mock.MagicMock()

        self.assertEqual(
            self.file_data,
            lib._get_output_certificate(cert_tool_output, report_func))
        report_func.assert_not_called()
    def test_success_request(self):
        cert_tool_output = """
some line
Certificate request stored in {0}
some other line
        """.format(self.file_path)
        report_func = mock.MagicMock()

        self.assertEqual(
            self.file_data,
            lib._get_output_certificate(cert_tool_output, report_func)
        )
        report_func.assert_not_called()
    def test_cannot_read_file(self):
        cert_tool_output = """
some line
Certificate request stored in {0}.bad
some other line
        """.format(self.file_path)
        report_func = reports.qdevice_certificate_import_error

        assert_raise_library_error(
            lambda: lib._get_output_certificate(cert_tool_output, report_func),
            (severity.ERROR, report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR, {
                "reason":
                "{0}.bad: No such file or directory".format(self.file_path),
            }))
Example #7
0
    def test_message_not_found(self):
        cert_tool_output = "some rubbish output"
        report_func = reports.qdevice_certificate_import_error

        assert_raise_library_error(
            lambda: lib._get_output_certificate(
                cert_tool_output,
                report_func
            ),
            (
                severity.ERROR,
                report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR,
                {
                    "reason": cert_tool_output,
                }
            )
        )