Exemplo n.º 1
0
 def test_dagda_history_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'history']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/history')
Exemplo n.º 2
0
 def test_dagda_check_container_full_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'check', '-c', '697f6f235558']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/check/containers/697f6f235558')
Exemplo n.º 3
0
 def test_dagda_monitor_stop_full_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'monitor', '69dbf26ab368', '--stop']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/monitor/containers/69dbf26ab368/stop')
Exemplo n.º 4
0
 def test_dagda_vuln_product_version_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'vuln', '--product', 'openldap', '--product_version', '2.2.20']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/vuln/products/openldap/2.2.20')
Exemplo n.º 5
0
 def test_dagda_vuln_exploit_info_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'vuln', '--exploit_db_info', '2002']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/vuln/exploit/2002/details')
Exemplo n.º 6
0
 def test_dagda_history_is_fp_with_version_full_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = ['dagda.py', 'history', 'jboss/wildfly', '--is_fp', 'openldap:2.2.20']
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(), parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(err, '/v1/history/jboss/wildfly/fp/openldap/2.2.20')
Exemplo n.º 7
0
 def test_dagda_docker_events_happy_path(self):
     os.environ['DAGDA_HOST'] = str('localhost')
     os.environ['DAGDA_PORT'] = str('50000')
     sys.argv = [
         'dagda.py', 'docker', 'events', '--event_from', 'FROM',
         '--event_type', 'TYPE', '--event_action', 'ACTION'
     ]
     parsed_args = DagdaCLIParser()
     try:
         execute_dagda_cmd(parsed_args.get_command(),
                           parsed_args.get_extra_args())
         self.fail()
     except requests.exceptions.ConnectionError as err:
         err = DagdaCLITestSuite._get_path(err)
         self.assertEqual(
             err,
             '/v1/docker/events?event_action=ACTION&event_from=FROM&event_type=TYPE'
         )
Exemplo n.º 8
0
def main(parsed_args):
    # -- Init
    cmd = parsed_args.get_command()
    parsed_args = parsed_args.get_extra_args()

    try:
        # Execute Dagda command
        r = execute_dagda_cmd(cmd=cmd, args=parsed_args)

        # -- Print cmd output
        if r is not None and r.content:
            output = r.content.decode('utf-8')
            try:
                print(json.dumps(json.loads(output), sort_keys=True, indent=4))
            except json.decoder.JSONDecodeError as err:
                DagdaLogger.get_logger().error('JSONDecodeError with the received response: "' + output + '"')
                DagdaLogger.get_logger().error(str(err))
    except BaseException as err:
        DagdaLogger.get_logger().error(str(err))
        traceback.print_exc()
Exemplo n.º 9
0
def main(parsed_args):
    # -- Init
    cmd = parsed_args.get_command()
    parsed_args = parsed_args.get_extra_args()

    try:
        # Execute Dagda command
        r = execute_dagda_cmd(cmd=cmd, args=parsed_args)

        # -- Print cmd output
        if r is not None and r.content:
            output = r.content.decode('utf-8')
            try:
                print(json.dumps(json.loads(output), sort_keys=True, indent=4))
            except json.decoder.JSONDecodeError as err:
                DagdaLogger.get_logger().error(
                    'JSONDecodeError with the received response: "' + output +
                    '"')
                DagdaLogger.get_logger().error(str(err))
    except BaseException as err:
        DagdaLogger.get_logger().error(str(err))