def test_invalid_file_arg(self):
     command = RCTCertCommand()
     try:
         command.main(["this_file_does_not_exist.crt"])
         self.fail("Expected InvalidCLIOptionError since no file does not exist.")
     except InvalidCLIOptionError, e:
         self.assertEqual("The specified certificate file does not exist.", str(e))
示例#2
0
 def test_file_arg_required(self):
     command = RCTCertCommand()
     try:
         command.main([])
         self.fail("Expected InvalidCLIOptionError since no file arg.")
     except InvalidCLIOptionError, e:
         self.assertEqual("You must specify a certificate file.", str(e))
 def test_invalid_file_arg(self):
     command = RCTCertCommand()
     try:
         command.main(["this_file_does_not_exist.crt"])
         self.fail("Expected InvalidCLIOptionError since no file does not exist.")
     except InvalidCLIOptionError as e:
         self.assertEqual("The specified certificate file does not exist.", str(e))
 def test_file_arg_required(self):
     command = RCTCertCommand()
     try:
         command.main([])
         self.fail("Expected InvalidCLIOptionError since no file arg.")
     except InvalidCLIOptionError, e:
         self.assertEqual("You must specify a certificate file.", str(e))
    def test_valid_x509_required(self, mock_create, mock_isfile):
        mock_create.side_effect = CertificateException("error!")
        mock_isfile.return_value = True
        command = RCTCertCommand()

        command._do_command = lambda: command._create_cert()
        try:
            command.main(["dummy-file.pem"])
            self.fail("Expected InvalidCLIOptionError since bad x509 file.")
        except InvalidCLIOptionError, e:
            self.assertEqual("Unable to read certificate file 'dummy-file.pem': error!", str(e))
    def test_valid_x509_required(self, mock_create, mock_isfile):
        mock_create.side_effect = CertificateException("error!")
        mock_isfile.return_value = True
        command = RCTCertCommand()

        command._do_command = lambda: command._create_cert()
        try:
            command.main(['dummy-file.pem'])
            self.fail("Expected InvalidCLIOptionError since bad x509 file.")
        except InvalidCLIOptionError, e:
            self.assertEqual(
                    "Unable to read certificate file 'dummy-file.pem': error!",
                    str(e))