{"id":16995774,"url":"https://github.com/qtc-de/tricot","last_synced_at":"2025-04-12T05:41:31.237Z","repository":{"id":38318505,"uuid":"354255949","full_name":"qtc-de/tricot","owner":"qtc-de","description":"Trivial Command Tester - End to end testing for executables, scripts and simple commands.","archived":false,"fork":false,"pushed_at":"2024-06-26T09:43:04.000Z","size":378,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-20T04:09:03.122Z","etag":null,"topics":["end-to-end-test-automation","end-to-end-testing","test-automation","testing","testing-framework","validation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qtc-de.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-03T09:56:02.000Z","updated_at":"2025-01-11T16:51:29.000Z","dependencies_parsed_at":"2024-06-25T21:19:31.656Z","dependency_job_id":"07953743-0ad3-4e21-a797-d5728d3ef832","html_url":"https://github.com/qtc-de/tricot","commit_stats":{"total_commits":226,"total_committers":3,"mean_commits":75.33333333333333,"dds":0.03539823008849563,"last_synced_commit":"b3aeabeb4105d55576156b51bc21e78db2abf247"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qtc-de%2Ftricot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qtc-de%2Ftricot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qtc-de%2Ftricot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qtc-de%2Ftricot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qtc-de","download_url":"https://codeload.github.com/qtc-de/tricot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525162,"owners_count":21118617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["end-to-end-test-automation","end-to-end-testing","test-automation","testing","testing-framework","validation"],"created_at":"2024-10-14T03:50:04.550Z","updated_at":"2025-04-12T05:41:31.207Z","avatar_url":"https://github.com/qtc-de.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### tricot\n\n----\n\n*tricot* is a *trivial command tester* that allows to test scripts, executables and commands for\nexpected behavior. Tests are configured within of *YAML* files and simply contain the command definitions\nto execute along with a set of desired validators. This approach makes *tricot* a simple solution\nfor end to end testing of command line applications.\n\n\n![](https://github.com/qtc-de/tricot/workflows/main/badge.svg?branch=main)\n![](https://github.com/qtc-de/tricot/workflows/develop/badge.svg?branch=develop)\n[![](https://img.shields.io/badge/version-1.13.0-blue)](https://github.com/qtc-de/tricot/releases)\n[![](https://img.shields.io/badge/packaging-pypi-blue)](https://pypi.org/project/tricot/)\n![](https://img.shields.io/badge/python-9%2b-blue)\n[![](https://img.shields.io/badge/license-GPL%20v3.0-blue)](https://github.com/qtc-de/tricot/blob/master/LICENSE)\n\n\nhttps://user-images.githubusercontent.com/49147108/183279190-d4148edb-ce40-443c-93c9-03c9b632e780.mp4\n\n\n### Installation\n\n----\n\n*tricot* can be build and installed as a [pip package](https://pypi.org/project/tricot/). The recommended\nway of installing is via [pipx](https://github.com/pypa/pipx):\n\n```console\n[user@host ~]$ pipx install tricot\n```\n\nYou can also build *tricot* from source by running the following commands:\n\n```console\n[user@host ~]$ git clone https://github.com/qtc-de/tricot\n[user@host ~]$ cd tricot\n[user@host ~/tricot]$ pipx install .\n```\n\n*tricot* also supports autocompletion for *bash*. To take advantage of autocompletion, you need to have the\n[completion-helpers](https://github.com/qtc-de/completion-helpers) project installed. If setup correctly, just\ncopying the [completion script](./resources/bash_completion.d/tricot) to your ``~/.bash_completion.d`` folder enables\nautocompletion.\n\n```console\n[user@host ~]$ cp resources/bash_completion.d/tricot ~/bash_completion.d/\n```\n\n\n### Usage\n\n----\n\n*tricot* tests are defined within of *YAML* files that can contain the following components:\n\n* **Testers**: Each *tricot YAML* file is required to define exactly one *Tester*. The *Tester*\n  basically describes the context of the current *YAML* file and sets attributes like it's *title*\n  or *error_mode*. Furthermore, *tricot YAML* files can contain references to other *Testers*,\n  which allows nesting *Testers*.\n\n* **Tests**: *tricot YAML* files can contain an arbitrary number of *Tests*. Each *Test* contains\n  the command you want to test and a set of validators that should be used to validate the commands\n  output.\n\n* **Validators**: As mentioned above, *Validators* are used within *Tests* to validate the result\n  of a test command. *Validators* usually apply to the command output, but they can validate side\n  effects as well. E.g. you can also use *Validators* to check whether a command created a specific\n  file on the file system.\n\n* **Plugins**: Plugins are mainly used to setup requirements for tests or to perform cleanup actions.\n  They run before the actual *Tests* start and perform cleanup actions after the *Tests* finished.\n  Plugins can e.g. be used to create files and directories required for the test, to run an operating\n  system command before the test or to spawn a *HTTP listener* that is available during the test.\n\n* **Containers**: When testing commands that interact with other systems, you probably want to run\n  your tests against a docker container. *Container* definitions within of *tricot YAML* files can\n  be used to start containers before your tests run. A container defined in a *YAML* file runs as\n  long as the *Tests* from the corresponding *YAML* file are executed. After all tests have finished,\n  the container is stopped.\n\n* **Variables**: *tricot YAML* files can contain variable definitions. These can be used to prevent\n  repetitions within of *Test* definitions. *Variables* are inherited when nesting *Testers*, which\n  allows the definition of global variables within the toplevel *Tester*, that can be used by all\n  sub *Testers*.\n\n* **Extractors**: Extractors allow you to extract parts of the command output of previous tests and\n  bind it to variables that can be used later on. This is useful if a test depends on the command\n  output of another test. If a test depends on the outcome of another test, you should use\n  [Conditionals](/docs/README.md#conditionals) instead.\n\n\nSounds too complicated? Let's look at some examples!\n\n\n### Examples\n\n----\n\nIn this section we list some examples on how to use *tricot*. The tests performed in these examples\ndo not really make sense and are only used for demonstration purposes. If you are interested in some\nreal word examples, you should check the [Projects that use tricot](#projects-that-use-tricot) section.\n\n**Example 1**:\n\n* Test definition:\n  ```yaml\n  tester:\n    title: Basic Usage\n    description: |-\n      Demonstrate the basic usage of tricot\n\n  variables:\n    passwd: /etc/passwd\n\n  tests:\n\n    - title: Test passwd File\n      description: |-\n        Test that our passwd file contains some expected user names.\n        Make sure that david is not contained within our passwd file.\n\n      command:\n        - cat\n        - ${passwd}\n      validators:\n        - status: 0\n        - contains:\n            ignore_case: False\n            values:\n              - root\n              - bin\n              - www-data\n            invert:\n              - david\n  ```\n* Output:\n  ```console\n  [qtc@kali example]$ tricot -v example1.yml\n  [+] Starting test: Basic Usage\n  [+]\n  [+]         1. Test passwd File... success.\n  ```\n\n**Example 2**:\n\n* Test definition:\n  ```yaml\n  tester:\n    title: Docker Integration\n    description: |-\n      An example for tricots docker integration\n\n  containers:\n    - name: 'nginx'\n      image: 'nginx:latest'\n      aliases:\n        DOCKER-nginx-IP: DOCKER-IP\n\n  tests:\n    - title: Test curl\n      description: |-\n        Test that our curl installation is working\n\n      command:\n        - curl\n        - ${DOCKER-IP}\n      validators:\n        - status: 0\n        - contains:\n            ignore_case: False\n            values:\n              - Welcome to nginx\n              - Thank you for using nginx\n\n    - title: Test wget\n      description: |-\n        Test that our wget installation is working\n\n      command:\n        - wget\n        - ${DOCKER-IP}\n      validators:\n        - status: 0\n        - file_contains:\n            - file: ./index.html\n              contains:\n                - Welcome to nginx\n                - Thank you for using nginx\n        - file_exists:\n            cleanup: True\n            files:\n              - './index.html'\n  ```\n* Output:\n  ```console\n  [qtc@kali example]$ tricot -v example2.yml\n  [+] Starting test: Docker Integration\n  [+]\n  [+]     Starting container: nginx\n  [+]         Image: nginx:latest\n  [+]         Network Mode: default\n  [+]\n  [+]     1. Test curl... success\n  [+]     2. Test wget... success\n  [+]\n  [+]     Stopping container: nginx\n  ```\n\n\n**Example 3**:\n\n* Test definition:\n  * ``example3.yml``:\n    ```yaml\n    tester:\n      title: Nested Testers\n      description: |-\n        An example for nested testers and plugins\n      error_mode: break\n\n    plugins:\n      - mkdir:\n          cleanup: True\n          force: True\n          dirs:\n            - ./www\n      - copy:\n          from:\n            - /etc/passwd\n          to:\n            - ./www\n      - http_listener:\n          port: 8000\n          dir: ./www\n\n    testers:\n      - ./example3/curl.yml\n      - ./example3/wget.yml\n    ```\n  * ``curl.yml``\n    ```yaml\n    tester:\n      title: curl Tester\n      description: |-\n        Test some curl commands\n\n    tests:\n\n      - title: Test passwd File\n        description: |-\n          Test whether the passwd file can be obtained from the\n          http_listener plugin.\n\n        command:\n          - curl\n          - http://127.0.0.1:8000/passwd\n        validators:\n          - status: 0\n          - contains:\n              values:\n                - root\n                - bin\n                - www-data\n    ```\n  * ``wget.yml``:\n    ```yaml\n    tester:\n      title: wget Tester\n      description: |-\n        Test some wget commands\n\n    plugins:\n      - cleanup:\n          items:\n            - ./passwd\n    tests:\n\n      - title: Test passwd File\n        description: |-\n          Test whether the passwd file can be obtained from the\n          http_listener plugin.\n\n        command:\n          - wget\n          - http://127.0.0.1:8000/passwd\n        validators:\n          - status: 0\n          - file_exists:\n              files:\n                - './passwd'\n          - file_contains:\n              - file: ./passwd\n                contains:\n                  - root\n                  - bin\n                  - nope\n    ```\n\n* Output:\n  ```console\n  [qtc@kali example]$ tricot -v example3.yml\n  [+] Starting test: Nested Testers\n  [+]\n  [+]     Starting test: curl Tester\n  [+]\n  [+]         1. Test passwd File... success\n  [+]\n  [+]     Starting test: wget Tester\n  [+]\n  [+]         1. Test passwd File... failed\n  [-]             - Caught ValidationException raised by the file_contains validator.\n  [-]               Configuration file: /opt/tricot/examples/example3/wget.yml\n  [-]\n  [-]               Validator run failed because of the following reason:\n  [-]               String 'nope' was not found in '/opt/tricot/examples/example3/passwd'.\n  [-]\n  [-]               Command: ['wget', 'http://127.0.0.1:8000/passwd']\n  [-]               Command exit code: 0\n  [-]               Command stdout:\n  [-]               Command stderr:\n  [-]                 --2021-09-08 07:35:33--  http://127.0.0.1:8000/passwd\n  [-]                 Connecting to 127.0.0.1:8000... connected.\n  [-]                 HTTP request sent, awaiting response... 200 OK\n  [-]                 Length: 3635 (3.5K) [application/octet-stream]\n  [-]                 Saving to: ‘passwd’\n  [-]\n  [-]                      0K ...                                                   100%  636M=0s\n  [-]\n  [-]                 2021-09-08 07:35:33 (636 MB/s) - ‘passwd’ saved [3635/3635]\n  [-]\n  [-]\n  [-]               Validator parameters:\n  [-]                 [\n  [-]                     {\n  [-]                         \"file\": \"./passwd\",\n  [-]                         \"contains\": [\n  [-]                             \"root\",\n  [-]                             \"bin\",\n  [-]                             \"nope\"\n  [-]                         ]\n  [-]                     }\n  [-]                 ]\n  [-]\n  [-]     Caught ValidationException while error mode is set to break.\n  [-]     Stopping test.\n  ```\n\n**Example 4**:\n\n* Test definition:\n  ```yaml\n  tester:\n    title: Extractors\n    Description: |-\n      An example for tricots extractor feature\n\n  tests:\n\n    - title: Check User\n      description: |-\n        Checks that user 1000:1000 exists and extracts the home\n        directory and the assigned shell to a variable.\n\n      command:\n        - cat\n        - /etc/passwd\n      extractors:\n        - regex:\n            pattern: '1000:1000:[^:]+:([^:]+):(.+)$'\n            variable: 'home-shell'\n            on_miss: 'break'\n            multiline: true\n      validators:\n        - contains:\n            values:\n              - 1000:1000\n\n\n    - title: Check Home and Shell\n      description: |-\n        Check that the home directory and assigned shell of user\n        1000:1000 exist.\n\n      command:\n        - ls\n        - ${home-shell-0-1}\n        - ${home-shell-0-2}\n      validators:\n        - status: 0\n  ```\n* Output:\n  ```console\n  [qtc@kali example]$ tricot -v example4.yml\n  [+] Starting test: Extractors\n  [+]\n  [+]     1. Check User... success\n  [+]     2. Check Home and Shell... success\n  ```\n\n\n### Projects that use tricot\n\n----\n\nIn this section we list some projects that are using *tricot* for testing. Not because we are proud of,\nbut only to provide you some more examples on how to use *tricot* for effective testing.\n\n* [beanshooter](https://github.com/qtc-de/beanshooter)\n* [ctfcred](https://github.com/qtc-de/ctfcred)\n* [remote-method-guesser](https://github.com/qtc-de/remote-method-guesser)\n* [slipit](https://github.com/usdAG/slipit)\n* [tricot](https://github.com/qtc-de/tricot)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqtc-de%2Ftricot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqtc-de%2Ftricot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqtc-de%2Ftricot/lists"}