Skip to content

Commit 1db24fe

Browse files
authored
Merge pull request #16 from b-long/feature/improved-integration-testing-running
Improved integration testing (running)
2 parents 26bc95b + de88dd3 commit 1db24fe

File tree

9 files changed

+74
-58
lines changed

9 files changed

+74
-58
lines changed

.github/workflows/build-golang-macos.yaml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,19 @@ jobs:
7676
# FIXME: Add more caching
7777
- name: Add gopy dependencies and build wheel
7878
run: |
79-
# Since we don't have our wheel build / install configured yet we use '--no-root'
80-
poetry install --no-root
81-
82-
source $(poetry env info --path)/bin/activate
83-
84-
# Add Go bin directory to PATH
85-
echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
86-
87-
go install golang.org/x/tools/cmd/goimports@latest
88-
89-
go install github.com/go-python/gopy@latest
90-
91-
poetry run pip install --upgrade setuptools wheel
92-
93-
gopy build --output=otdf_python -vm=python3 .
94-
95-
poetry run python3 setup.py bdist_wheel
79+
./ci-build.sh
9680
9781
- name: Test Python wheel
9882
run: |
9983
# Test wheel installation
100-
pip install dist/otdf_python-0.0.15-py3-none-any.whl
84+
pip install dist/otdf_python-0.1.0-py3-none-any.whl
10185
10286
# Test wheel functionality
10387
# python3 validate_otdf_python.py
10488
10589
- uses: ./.github/workflows/platform-integration-test.yaml
10690
with:
107-
wheel: dist/otdf_python-0.0.15-py3-none-any.whl
91+
wheel: dist/otdf_python-0.1.0-py3-none-any.whl
10892

10993
# release:
11094
# needs: build

.github/workflows/build-golang-ubuntu.yaml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,7 @@ jobs:
5757
# FIXME: Add more caching
5858
- name: Add gopy dependencies and build wheel
5959
run: |
60-
# Since we don't have our wheel build / install configured yet we use '--no-root'
61-
poetry install --no-root
62-
63-
source $(poetry env info --path)/bin/activate
64-
65-
# Add Go bin directory to PATH
66-
echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
67-
68-
go install golang.org/x/tools/cmd/goimports@latest
69-
70-
go install github.com/go-python/gopy@latest
71-
72-
poetry run pip install --upgrade setuptools wheel
73-
74-
gopy build --output=otdf_python -vm=python3 .
75-
76-
poetry run python3 setup.py bdist_wheel
77-
60+
./ci-build.sh
7861
7962
- name: Check existing workspace content
8063
run: |
@@ -84,20 +67,20 @@ jobs:
8467
- name: Test Python wheel
8568
run: |
8669
# Test wheel installation
87-
pip install dist/otdf_python-0.0.15-py3-none-any.whl
70+
pip install dist/otdf_python-0.1.0-py3-none-any.whl
8871
8972
# DISABLED: Need to figure out Ubuntu nested VM
9073
# Test wheel functionality
9174
# python3 validate_otdf_python.py
9275
9376
- uses: actions/cache/restore@v4
9477
with:
95-
path: dist/otdf_python-0.0.15-py3-none-any.whl
78+
path: dist/otdf_python-0.1.0-py3-none-any.whl
9679
key: ${{ runner.os }}-data-${{ github.sha }}
9780

9881
- uses: actions/cache/save@v4
9982
with:
100-
path: dist/otdf_python-0.0.15-py3-none-any.whl
83+
path: dist/otdf_python-0.1.0-py3-none-any.whl
10184
key: ${{ runner.os }}-data-${{ github.sha }}
10285
restore-keys: |
10386
${{ runner.os }}-data-
@@ -106,4 +89,4 @@ jobs:
10689
needs: build
10790
uses: ./.github/workflows/platform-integration-test.yaml
10891
with:
109-
wheel: dist/otdf_python-0.0.15-py3-none-any.whl
92+
wheel: dist/otdf_python-0.1.0-py3-none-any.whl

.github/workflows/platform-integration-test.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: actions/cache/restore@v4
2727
with:
28-
path: dist/otdf_python-0.0.15-py3-none-any.whl
28+
path: dist/otdf_python-0.1.0-py3-none-any.whl
2929
key: ${{ runner.os }}-data-${{ github.sha }}
3030

3131
- name: Prove that the input file is available
@@ -109,6 +109,29 @@ jobs:
109109
grpcurl -plaintext localhost:8080 list && \
110110
grpcurl -plaintext localhost:8080 kas.AccessService/PublicKey
111111
112+
- name: Set up Python
113+
uses: actions/setup-python@v4
114+
with:
115+
python-version: '3.11'
116+
117+
- name: Validate the Python SDK
118+
env:
119+
OPENTDF_CLIENT_ID: "opentdf-sdk"
120+
OPENTDF_CLIENT_SECRET: "secret"
121+
OPENTDF_HOSTNAME: "localhost:8080"
122+
OIDC_TOKEN_ENDPOINT: "http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token"
123+
OPENTDF_KAS_URL: "http://localhost:8080/kas"
124+
run: |
125+
mkdir validation
126+
wheel="$(basename ${{ inputs.wheel }} )"
127+
cp -v "${{ inputs.wheel }}" validation/
128+
cp -v validate_otdf_python.py validation/
129+
cd validation
130+
python -m venv .venv
131+
source .venv/bin/activate
132+
pip install ./"$wheel"
133+
python validate_otdf_python.py
134+
112135
# - name: Validate the SDK through the command line interface
113136
# run: |
114137
# printf 'here is some data to encrypt' > data

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude: |
77
# See https://pre-commit.com/hooks.html for more hooks#
88
repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.6.0
10+
rev: v5.0.0
1111
hooks:
1212
- id: check-yaml
1313
- id: end-of-file-fixer
@@ -40,7 +40,7 @@ repos:
4040

4141
- repo: https://github.com/astral-sh/ruff-pre-commit
4242
# Ruff version.
43-
rev: v0.6.9
43+
rev: v0.7.4
4444
hooks:
4545
# Run the linter.
4646
- id: ruff

ci-build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -eou pipefail
4+
5+
# Since we don't have our wheel build / install configured yet we use '--no-root'
6+
poetry install --no-root
7+
8+
source $(poetry env info --path)/bin/activate
9+
10+
# Add Go bin directory to PATH
11+
echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
12+
13+
go install golang.org/x/tools/cmd/goimports@latest
14+
15+
go install github.com/go-python/gopy@latest
16+
17+
poetry run pip install --upgrade setuptools wheel
18+
19+
gopy build --output=otdf_python -vm=python3 .
20+
21+
poetry run python3 setup.py bdist_wheel

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "otdf-python"
33
# Should match 'setup.py' version number (used for gopy/pybindgen)
4-
version = "0.0.15"
4+
version = "0.1.0"
55
description = "Unofficial OpenTDF SDK for Python."
66
authors = ["b-long <[email protected]>"]
77
readme = "README.md"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
url="https://github.com/b-long/opentdf-python-sdk",
2525
package_data={"otdf_python": ["*.so"]},
2626
# Should match 'pyproject.toml' version number
27-
version="0.0.15",
27+
version="0.1.0",
2828
author_email="[email protected]",
2929
include_package_data=True,
3030
)

setup_ci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def build_extension(self, ext: Extension):
8181

8282
setuptools.setup(
8383
name="otdf_python",
84-
version="0.0.15",
84+
version="0.1.0",
8585
author="b-long",
8686
description="Unofficial OpenTDF SDK for Python.",
8787
long_description_content_type="text/markdown",

validate_otdf_python.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import tempfile
66
from pathlib import Path
77
from zipfile import is_zipfile
8+
from os import environ
89

910
from otdf_python.gotdf_python import EncryptionConfig
1011

11-
SOME_PLAINTEXT_FILE = Path(__file__).parent / "go.mod"
12-
1312

1413
def verify_hello():
1514
from otdf_python.gotdf_python import Hello
@@ -22,11 +21,14 @@ def _get_configuration() -> EncryptionConfig:
2221
platformEndpoint = "localhost:8080"
2322

2423
config: EncryptionConfig = EncryptionConfig(
25-
ClientId="opentdf-sdk",
26-
ClientSecret="secret",
27-
PlatformEndpoint=platformEndpoint,
28-
TokenEndpoint="http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token",
29-
KasUrl=f"http://{platformEndpoint}/kas",
24+
ClientId=environ.get("OPENTDF_CLIENT_ID", "opentdf-sdk"),
25+
ClientSecret=environ.get("OPENTDF_CLIENT_SECRET", "secret"),
26+
PlatformEndpoint=environ.get("OPENTDF_HOSTNAME", platformEndpoint),
27+
TokenEndpoint=environ.get(
28+
"OIDC_TOKEN_ENDPOINT",
29+
"http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token",
30+
),
31+
KasUrl=environ.get("OPENTDF_KAS_URL", f"http://{platformEndpoint}/kas"),
3032
# FIXME: Be careful with binding the 'DataAttributes' field on this struct.
3133
#
3234
# In golang, this is initialized as []string , but passing
@@ -77,6 +79,9 @@ def verify_encrypt_file() -> None:
7779
"The output path should not exist before calling 'EncryptFile()'."
7880
)
7981

82+
SOME_PLAINTEXT_FILE = Path(tmpDir) / "new-file.txt"
83+
SOME_PLAINTEXT_FILE.write_text("Hello world")
84+
8085
outputFilePath = EncryptFile(
8186
inputFilePath=str(SOME_PLAINTEXT_FILE),
8287
outputFilePath=str(SOME_ENCRYPTED_FILE),
@@ -87,10 +92,10 @@ def verify_encrypt_file() -> None:
8792
if not SOME_ENCRYPTED_FILE.exists():
8893
raise ValueError("The output file does not exist!")
8994

90-
if not (
91-
SOME_ENCRYPTED_FILE.stat().st_size > 2500
92-
and is_zipfile(SOME_ENCRYPTED_FILE)
93-
):
95+
encrypted_file_size = SOME_ENCRYPTED_FILE.stat().st_size
96+
print(f"The encrypted file size is {encrypted_file_size}")
97+
98+
if not (encrypted_file_size > 1500 and is_zipfile(SOME_ENCRYPTED_FILE)):
9499
raise ValueError("The output file has unexpected content!")
95100

96101
# breakpoint()

0 commit comments

Comments
 (0)