Giter Club home page Giter Club logo

enochecker_test's Introduction

enochecker_test PyPI version Build Status Lines of code

Automatically test services/checker using the enochecker API

Usage

enochecker_test can be used to run tests against a checker, optionally you can specify wich tests to run e.g. enochecker_test test_getflag[0] test_exploit_per_exploit_id will run only the first getflag test and all exploit_per_exploit_id tests.

usage: enochecker_test [-h] [-a CHECKER_ADDRESS] [-p {1..65535}] [-A SERVICE_ADDRESS] [testcase ...]

Utility for testing checkers that implement the enochecker API

positional arguments:
  testcase              Specify the tests that should be run in the syntax expected by pytest, e.g. test_getflag. If no test is specified, all tests will be run.

options:
  -h, --help            show this help message and exit
  -a CHECKER_ADDRESS, --checker-address CHECKER_ADDRESS
                        The address on which the checker is listening (defaults to the ENOCHECKER_TEST_CHECKER_ADDRESS environment variable)
  -p {1..65535}, --checker-port {1..65535}
                        The port on which the checker is listening (defaults to ENOCHECKER_TEST_CHECKER_PORT environment variable)
  -A SERVICE_ADDRESS, --service-address SERVICE_ADDRESS
                        The address on which the service is listening (defaults to ENOCHECKER_TEST_SERVICE_ADDRESS environment variable)

enochecker_test's People

Contributors

christophwitzko avatar drruhe avatar ldruschk avatar thehllm avatar trolldemorted avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

thehllm drruhe fwc

enochecker_test's Issues

Example for partial testing runs everything

I just copied enochecker_test test_getflag[0] from the readme and it ran all tests.
It was supposed to run only the first testflag. In particular enochecker_test test_getflag[0] and enochecker_test rant the same amount of tests.

Increase pytest verbosity

Can we add -vvv to the pytest.main call (honest question, I have never used pytest.main before)?

Right now I can't see both sides' values of an assertion, and since the sample service tests pass locally I have no clue what could be going wrong in github actions.

I do think the assert rewriting worked, because it clearly shows the offending line:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

round_id = 19, havoc_id = 3, service_address = '10.1.0.216'
checker_url = 'http://localhost:8000', unique_variant_index = 3
expected_result = <CheckerTaskResult.CHECKER_TASK_RESULT_INTERNAL_ERROR: 'INTERNAL_ERROR'>

    def _test_havoc(
        round_id,
        havoc_id,
        service_address,
        checker_url,
        unique_variant_index=None,
        expected_result=CheckerTaskResult.CHECKER_TASK_RESULT_OK,
    ):
        if unique_variant_index is None:
            unique_variant_index = havoc_id
        request_message = _create_request_message(
            "havoc",
            round_id,
            havoc_id,
            service_address,
            unique_variant_index=unique_variant_index,
        )
        msg = _jsonify_request_message(request_message)
        r = requests.post(
            f"{checker_url}", data=msg, headers={"content-type": "application/json"}
        )
        assert r.status_code == 200
        result_message: CheckerResultMessage = jsons.loads(
            r.content, CheckerResultMessage, key_transformer=jsons.KEY_TRANSFORMER_SNAKECASE
        )
>       assert CheckerTaskResult(result_message.result) == expected_result
E       AssertionError

/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/enochecker_test/base.py:302: AssertionError

Randomize taskchainId

at least include a random prefix to allow rerunning without needing to clean up the database

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.