Beispiel #1
0
 def __init__(self):
     super(DagdaCLIParser, self).__init__()
     self.parser = DagdaGlobalParser(prog='dagda.py',
                                     usage=dagda_global_parser_text,
                                     add_help=False)
     self.parser.add_argument('command',
                              choices=[
                                  'vuln', 'check', 'history', 'start',
                                  'monitor', 'docker', 'agent'
                              ])
     self.parser.add_argument('-h', '--help', action=_HelpAction)
     self.parser.add_argument('-v',
                              '--version',
                              action='version',
                              version='%(prog)s 0.9.0')
     self.args, self.unknown = self.parser.parse_known_args()
     if self.get_command() == 'vuln':
         self.extra_args = VulnCLIParser()
     elif self.get_command() == 'check':
         self.extra_args = CheckCLIParser()
     elif self.get_command() == 'history':
         self.extra_args = HistoryCLIParser()
     elif self.get_command() == 'start':
         self.extra_args = StartCLIParser()
     elif self.get_command() == 'monitor':
         self.extra_args = MonitorCLIParser()
     elif self.get_command() == 'docker':
         self.extra_args = DockerCLIParser()
     elif self.get_command() == 'agent':
         self.extra_args = AgentCLIParser()
 def test_check_full_happy_path_3(self):
     sys.argv = ['dagda.py', 'history', 'jboss/wildfly', '--fp', 'mongodb']
     parsed_args = HistoryCLIParser()
     self.assertEqual(parsed_args.get_docker_image_name(), 'jboss/wildfly')
     self.assertEqual(parsed_args.get_fp()[0], 'mongodb')
     self.assertEqual(parsed_args.get_fp()[1], None)
     self.assertEqual(parsed_args.get_is_fp(), None)
 def test_check_exit_1(self):
     sys.argv = ['dagda.py', 'history', '--id', '43a6ca974743', '--fp', 'openldap:2.2.20']
     with self.assertRaises(SystemExit) as cm:
         HistoryCLIParser()
     self.assertEqual(cm.exception.code, 1)
 def test_is_fp(self):
     sys.argv = ['dagda.py', 'history', 'jboss/wildfly', '--is_fp', 'openldap:2.2.20']
     args = HistoryCLIParser()
     self.assertEqual(args.get_is_fp(), ('openldap', '2.2.20'))
 def test_none_fp(self):
     self.assertIsNone(HistoryCLIParser()._parse_product_and_version(None))
 def test_check_full_happy_path(self):
     sys.argv = ['dagda.py', 'history', 'jboss/wildfly']
     parsed_args = HistoryCLIParser()
     self.assertEqual(parsed_args.get_docker_image_name(), 'jboss/wildfly')