def test_qdevice_net_sign_certificate_request(self):
     self.base_test(
         lambda: lib.qdevice_net_sign_certificate_request(
             self.lib_env,
             "certificate request",
             "cluster name"
         )
     )
示例#2
0
 def test_qdevice_net_sign_certificate_request(self):
     self.base_test(
         lambda: lib.qdevice_net_sign_certificate_request(
             self.lib_env,
             "certificate request",
             "cluster name"
         )
     )
示例#3
0
    def test_bad_input(self, mock_qdevice_func):
        qdevice_func_input = "certificate request".encode("utf-8")
        cluster_name = "clusterName"

        assert_raise_library_error(
            lambda: lib.qdevice_net_sign_certificate_request(
                self.lib_env, qdevice_func_input, cluster_name),
            (severity.ERROR, report_codes.INVALID_OPTION_VALUE, {
                "option_name": "qnetd certificate request",
                "option_value": qdevice_func_input,
                "allowed_values": ["base64 encoded certificate"],
            }))

        mock_qdevice_func.assert_not_called()
示例#4
0
    def test_success(self, mock_qdevice_func):
        qdevice_func_input = "certificate request".encode("utf-8")
        qdevice_func_output = "signed certificate".encode("utf-8")
        mock_qdevice_func.return_value = qdevice_func_output
        cluster_name = "clusterName"

        self.assertEqual(
            base64.b64encode(qdevice_func_output),
            lib.qdevice_net_sign_certificate_request(
                self.lib_env, base64.b64encode(qdevice_func_input),
                cluster_name))

        mock_qdevice_func.assert_called_once_with("mock_runner",
                                                  qdevice_func_input,
                                                  cluster_name)
    def test_success(self, mock_qdevice_func):
        qdevice_func_input = "certificate request".encode("utf-8")
        qdevice_func_output = "signed certificate".encode("utf-8")
        mock_qdevice_func.return_value = qdevice_func_output
        cluster_name = "clusterName"

        self.assertEqual(
            base64.b64encode(qdevice_func_output),
            lib.qdevice_net_sign_certificate_request(
                self.lib_env,
                base64.b64encode(qdevice_func_input),
                cluster_name
            )
        )

        mock_qdevice_func.assert_called_once_with(
            "mock_runner",
            qdevice_func_input,
            cluster_name
        )
    def test_bad_input(self, mock_qdevice_func):
        qdevice_func_input = "certificate request".encode("utf-8")
        cluster_name = "clusterName"

        assert_raise_library_error(
            lambda: lib.qdevice_net_sign_certificate_request(
                self.lib_env,
                qdevice_func_input,
                cluster_name
            ),
            (
                severity.ERROR,
                report_codes.INVALID_OPTION_VALUE,
                {
                    "option_name": "qnetd certificate request",
                    "option_value": qdevice_func_input,
                    "allowed_values": ["base64 encoded certificate"],
                }
            )
        )

        mock_qdevice_func.assert_not_called()