# Pynt for pytest

## **What is Pytest?**

{% hint style="info" %}
💡 [**pytest**](https://pytest.org/) is a powerful testing framework for Python applications, designed for simple unit tests as well as complex functional testing. It supports fixtures, parameterized testing, and assertions, making it highly adaptable for a variety of testing needs. With its easy-to-read syntax and extensive plugin ecosystem, pytest helps streamline the testing process for Python developers, ensuring robust and maintainable test suites.
{% endhint %}

<figure><img src="https://3462681674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZKwBF6q0tAGXlIih38HL%2Fuploads%2FvIdut5i2Rjdj0vziXT5M%2FPyTest2.png?alt=media&#x26;token=72218f7a-f643-4e71-83eb-c82516dde0e1" alt="" width="188"><figcaption><p>PyTest</p></figcaption></figure>

***

## **Pynt's integration with pytest**

As part of its [API security testing](https://docs.pynt.io/documentation/api-security-testing) suit, Pynt allows seamless [integration](https://docs.pynt.io/documentation/security-testing-integrations/pynt-with-testing-frameworks/broken-reference) with any Pytest API testing.

By integrating Pynt with pytest, you can leverage the power of this vast platform while enhancing your API security. Pynt automatically generates context-aware security tests based on your pytest test scripts, enabling you to identify vulnerabilities early in the development cycle and reduce the risk of security issues in production.

***

## Quick start

1. First, make sure Pynt's [prerequisites](https://docs.pynt.io/documentation/api-security-testing/prerequisites-for-running-pynt-scans) are met.
2. Follow the instructions to install Pynt container [here](https://docs.pynt.io/documentation/api-security-testing/how-to-install-pynt-cli).
3. Then, continue with the below example.

***

## Example

[goat\_functional\_test.py](https://raw.githubusercontent.com/pynt-io/pynt/main/goat_functional_tests/goat_functional_test.py) is a python based tester for goat (our vulnerable application) that we use to test the functionality of goat, we run it with:&#x20;

```sh
pytest goat_functional_test.py
```

Now, to run Pynt on it, we run:

```bash
pynt command --cmd "pytest goat_functional_test.py"
```

***

## SSL Support

### Automatic Self-signed certificates

Pynt can automatically set your pytest to use self signed certificate. use the flag `--self-signed`

```bash
pynt command --cmd "<your test command>" --self-signed
```

If your functional test is enforcing SSL certificate verification (e.g. https) you will need to provide Pynt a certificate, If your client need a specific certificate, provide the path to it with `--ca_path`

***

### Manually providing certificates

```sh
pynt command --cmd "<your test command>" --ca-path <path to certificate file>
```

If your client does not use a specific certificate you will need to generate a certificate file and provide it to Pynt:

***

### Generate a certificate (Linux)

1\) Download [make\_certificate.sh](https://raw.githubusercontent.com/pynt-io/pynt/main/command/make_certificate.sh)

2\) Download [openssl.cnf](https://raw.githubusercontent.com/pynt-io/pynt/main/command/openssl.cnf)

3\) `chmod +x make_certificate.sh`

4\) Generate the certificate: `./make_certificate.sh`&#x20;

***

### Run Pynt with the generated certificate

Use the export REQUESTS\_CA\_BUNDLE before your command to instruct your functional test to use the new certificate and provide the path ti the certificate with --ca-path to instruct Pynt to use the generated certificate.

{% code overflow="wrap" %}

```sh
pynt command --cmd "export REQUESTS_CA_BUNDLE=rootCA.crt && python3 <your command here>" --ca-path rootCA.pem
```

{% endcode %}

***

{% hint style="info" %}
💡 **Pynt CLI Troubleshooting**: If you're encountering issues with Pynt's CLI, visit the [**Pynt CLI Troubleshooting Guide**](https://docs.pynt.io/documentation/api-security-testing/pynt-scans-troubleshooting/pynt-cli-troubleshooting) for solutions and troubleshooting tips.
{% endhint %}

{% hint style="info" %}
💡 **Still Need Help?** For any questions or troubleshooting, reach out to the [**Pynt Community Support**](https://www.pynt.io/community).
{% endhint %}
