Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Commit

Permalink
Further README clarifications for running proxy tests
Browse files Browse the repository at this point in the history
It's not necessary to comment/uncomment the datasaver; just
deleting JSON files will cause it to regenerate them if needed.
However, it is necessary to get a fresh token whenever you're
running tests that require it.
  • Loading branch information
eloquence authored and sssoleileraaa committed Dec 11, 2020
1 parent e43f835 commit 2a3e7e0
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,36 +108,42 @@ Note: Some tests alter source and conversation data on the server so you may nee

In order to generate cassettes for tests that make API calls over qrexec, you'll need to run the server and proxy on a separate VM. If this is the first time you are generating cassettes, first follow the steps outlined in the [Test setup for qrexec communication](#test-setup-for-qrexec-communication) section, which will help you set up a new VM called `sd-dev-proxy`.

Once your proxy are set up, follow these steps:
Once your proxy VM is set up, follow these steps:

1. Start the server in a docker container on `sd-dev-proxy` by running:

```bash
NUM_SOURCES=5 make dev
```

2. [Skip if adding a new test] Delete the cassettes you wish to regenerate or just delete all json files by running:
2. Delete the cassettes you wish to regenerate or just delete all JSON files by running:

```bash
rm data/*.json
```

3. Comment out the `@qrexec_datasaver` decorator above the test you want to generate a new cassette for or just generate all new cassettes by commenting out the decorator above all methods in the `test_apiproxy.py::TestAPIProxy` class.
If you are only adding a new test and not modifying existing ones, you can
skip this step, but you still need to remove the authentication setup during
cassette generation. Otherwise you will get 403 errors for API endpoints that
require a valid token. Remove the setup cassette by running:

4. Make qrexec calls to the server and collect real response data:
```bash
rm data/setup_method.json
```

```bash
make test TESTS=tests/test_apiproxy.py
```
(You can reinstate the unmodified version later.)

5. Uncomment the `@qrexec_datasaver` decorator wherever you commented it out.
6. Record new cassettes from the response data collected in step 4:
3. Make qrexec calls to the server and collect response data. To run all proxy
tests:

```bash
make test TESTS=tests/test_apiproxy.py
```

**Note:** If you get a 403 error it's becuase the test is trying to reuse an old TOTP code, so wait for 60 seconds and try again. Some tests alter source and conversation data on the server so you should restart the server in between test runs.
**Note:** If you get a 403 error it may also be because the test is trying to
reuse an old TOTP code, so wait for 60 seconds and try again. Some tests alter
source and conversation data on the server so you should restart the server in
between test runs.

## Test setup for qrexec communication

Expand Down

0 comments on commit 2a3e7e0

Please sign in to comment.