예제 #1
0
    def test_main_required_args(self):
        """Test in-toto-keygen CLI tool with required arguments. """
        args = ["in_toto_keygen.py"]

        with patch.object(sys, 'argv', args + ["bob"]), \
          self.assertRaises(SystemExit):
            in_toto_keygen_main()
예제 #2
0
    def test_main_wrong_args(self):
        """Test CLI command with missing arguments. """
        wrong_args_list = [["in_toto_keygen.py"], ["in_toto_keygen.py", "-r"],
                           ["in_toto_keygen.py", "-p", "-b", "1024", "bob"]]
        password = "******"

        for wrong_args in wrong_args_list:
            with patch.object(sys, 'argv', wrong_args), patch(
                    "getpass.getpass",
                    return_value=password), self.assertRaises(SystemExit):
                in_toto_keygen_main()
예제 #3
0
 def test_main_optional_args(self):
     """Test CLI command keygen with optional arguments. """
     args = ["in_toto_keygen.py"]
     password = "******"
     with patch.object(sys, 'argv', args + ["-p", "bob"]), \
       patch("getpass.getpass", return_value=password), self.assertRaises(
       SystemExit):
         in_toto_keygen_main()
     with patch.object(sys, 'argv', args + ["-p", "bob", "3072"]), \
       patch("getpass.getpass", return_value=password), self.assertRaises(
       SystemExit):
         in_toto_keygen_main()