-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(xtest): Convert to pytest framework (#155)
- Loading branch information
1 parent
1f2ee4c
commit 803f921
Showing
16 changed files
with
245 additions
and
1,782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,53 @@ | ||
# tests | ||
Tests for OpenTDF | ||
# Tests for OpenTDF | ||
|
||
## [Cross-client compatibility tests](xtests) | ||
|
||
1) `cd xtest` | ||
2) `npm ci && npm i @opentdf/client@CLIENT_VERSION` | ||
3) `pip3 install -r ./requirements.txt` | ||
4) `tilt up` | ||
|
||
### To use a Github Package Manager Version | ||
|
||
Before doing theabove, [configure Github packages as the scope provider for opentdf](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages) | ||
|
||
``` | ||
npm login --scope=@opentdf --registry=https://npm.pkg.github.com | ||
``` | ||
|
||
## [Vulnerability](vulnerability) | ||
|
||
Automated checks for vulnerabilities identified during penetration testing | ||
> Automated checks for vulnerabilities identified during penetration testing | ||
Place to run frontend and backend together locally. | ||
Check Backend "Quick Start and Development" for [Prerequisites](https://github.com/opentdf/backend#prerequisites) | ||
|
||
1) delete `ctlptl delete cluster kind-kind` and clear saved related images in docker if you've run integration tests locally from other folder | ||
1) delete the cluster with `ctlptl delete cluster kind-kind` | ||
and clear saved related images in docker | ||
if you've run integration tests locally from other folder | ||
2) run `ctlptl create cluster kind --registry=ctlptl-registry` | ||
3) `cd vulnerability` | ||
4) `tilt up` | ||
|
||
If you are running locally on mac frontend 'npm run build' step may take too long. Possible solution is run this | ||
command `npm run build` and change frontend/Dockerfile line `RUN npm run build` to `COPY build/ build/` so it won`t | ||
run it inside docker. Be careful not to push this changes, we won't need that to CI machines that runs on linux. | ||
If you are running locally on mac, | ||
frontend 'npm run build' step may take too long. | ||
A possible solution is to run `npm run build` | ||
and change `frontend/Dockerfile` line `RUN npm run build` to `COPY build/ build/` | ||
so it won't run it inside docker. | ||
Be careful not to push these changes, | ||
we won't need that to CI machines that runs on linux. | ||
|
||
## [Abacus and API integration tests](abacus-and-api-integration-tests) | ||
|
||
Automated Playwright tests for Abacus application run against the latest versions of frontend and backend together + API tests for OpenTDF backend services | ||
> Automated Playwright tests for the Abacus application | ||
> run against the latest versions of frontend and backend together | ||
> with API tests for OpenTDF backend services. | ||
Check Backend "Quick Start and Development" for [Prerequisites](https://github.com/opentdf/backend#prerequisites) | ||
|
||
1) delete `ctlptl delete cluster kind-kind` and clear saved related images in docker if you've run integration tests locally from other folder | ||
1) delete `ctlptl delete cluster kind-kind` | ||
and clear saved related images in docker | ||
if you've run integration tests locally from another folder | ||
2) run `ctlptl create cluster kind --registry=ctlptl-registry` | ||
3) `cd abacus-and-api-integration-tests` | ||
4) `tilt up` | ||
|
||
## Cross-client compatibility tests (xtests) | ||
1) `cd xtest` | ||
2) `npm ci && npm i @opentdf/client@CLIENT_VERSION` | ||
3) `pip3 install -r ./requirements.txt` | ||
4) `tilt up` | ||
|
||
### To use a Github Package Manager Version | ||
|
||
Before doing theabove, [configure Github packages as the scope provider for opentdf](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages) | ||
|
||
``` | ||
npm login --scope=@opentdf --registry=https://npm.pkg.github.com | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# x-test | ||
|
||
> Compatibility tests for opentdf client libraries and tools. | ||
|
||
Requirements: | ||
|
||
- go 1.22.3 | ||
- node 20 | ||
- python 3.10 | ||
- jdk 11 | ||
|
||
## Bringing up the platform backend (macOS) | ||
|
||
1. checkout platform (`git checkout https://github.com/opentdf/platform`) | ||
2. switch to the the platform folder (`cd platform`) | ||
3. configure and initialize the platform () | ||
a. `cp opentdf-dev.yaml opentdf.yaml` & edit the yaml if needed | ||
b. `.github/scripts/init-temp-keys.sh` | ||
c. `sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./keys/localhost.crt` | ||
i. To remove, `sudo security delete-certificate -c "localhost"` | ||
4. Bring up background services, `docker compose up` | ||
5. Add sample users and realm to keycloak, `go run ./service provision keycloak` | ||
6. Add sample attributes and metadata, `go run ./service provision fixtures` | ||
7. start server in background, `go run ./service start` | ||
|
||
## Testing with Released Software | ||
|
||
```sh | ||
pytest --sdks "js go" --container nano | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--large", | ||
action="store_true", | ||
help="generate a large (greater than 4 GiB) file for testing", | ||
) | ||
parser.addoption( | ||
"--sdks", help="select which sdks to run by default, unless overridden" | ||
) | ||
parser.addoption("--sdks-decrypt", help="select which sdks to run for decrypt only") | ||
parser.addoption("--sdks-encrypt", help="select which sdks to run for encrypt only") | ||
parser.addoption("--containers", help="which container formats to test") | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
if "size" in metafunc.fixturenames: | ||
metafunc.parametrize("size", ["large" if metafunc.config.getoption("large") else "small"]) | ||
if "encrypt_sdk" in metafunc.fixturenames: | ||
if metafunc.config.getoption("--sdks-encrypt"): | ||
encrypt_sdks = metafunc.config.getoption("--sdks-encrypt").split() | ||
elif metafunc.config.getoption("--sdks"): | ||
encrypt_sdks = metafunc.config.getoption("--sdks").split() | ||
else: | ||
encrypt_sdks = ["js", "go", "java"] | ||
metafunc.parametrize("encrypt_sdk", encrypt_sdks) | ||
if "decrypt_sdk" in metafunc.fixturenames: | ||
if metafunc.config.getoption("--sdks-decrypt"): | ||
decrypt_sdks = metafunc.config.getoption("--sdks-decrypt").split() | ||
elif metafunc.config.getoption("--sdks"): | ||
decrypt_sdks = metafunc.config.getoption("--sdks").split() | ||
else: | ||
decrypt_sdks = ["js", "go", "java"] | ||
metafunc.parametrize("decrypt_sdk", decrypt_sdks) | ||
if "container" in metafunc.fixturenames: | ||
if metafunc.config.getoption("--containers"): | ||
containers = metafunc.config.getoption("--container").split() | ||
else: | ||
containers = ["nano", "ztdf"] | ||
metafunc.parametrize("container", containers) | ||
|
||
|
||
@pytest.fixture | ||
def pt_file(tmp_dir, size): | ||
pt_file = f"{tmp_dir}test-plain-{size}.txt" | ||
length = (5 * 2**30) if size == "large" else 128 | ||
with open(pt_file, "w") as f: | ||
for i in range(0, length, 16): | ||
f.write("{:15,d}\n".format(i)) | ||
return pt_file | ||
|
||
|
||
@pytest.fixture | ||
def tmp_dir(): | ||
dname = "tmp/" | ||
isExist = os.path.exists(dname) | ||
if not isExist: | ||
os.makedirs(dname) | ||
return dname |
Oops, something went wrong.