| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 |
GTA Integration Tests
Requirements
- Python 3.11+
- Install dependencies:
pip install pytest pytest-html requests pyyaml pyjwt cryptography
Configuration
Edit config.yaml with the actual addresses of GTA Server and Agent:
server:
host: "127.0.0.1"
port: 8080
agent:
host: "127.0.0.1"
port: 8090
# Minimum seconds between consecutive RESTful requests from a single client,
# to avoid the service rejecting requests fired too fast.
request_interval: 0.5
Port reachability is checked automatically on the first request. A misconfigured address will cause an immediate error.
Running Tests
Use run_tests.sh to run by level, default is p1:
./run_tests.sh # equivalent to p1, runs p0 + p1
./run_tests.sh p0 # smoke tests only, fastest
./run_tests.sh p1 # p0 + p1, daily CI
./run_tests.sh p2 # p0 + p1 + p2, pre-release
./run_tests.sh p3 # full suite, includes edge cases
You can also invoke pytest directly, e.g. to run a single module:
pytest tests/service_challenge/
pytest tests/ -m "p0 or p1" -k "nonce"
The test report is written to report.html by default.
Test Levels
| Mark | Description | When to run |
|---|---|---|
| p0 | Smoke tests | Every commit |
| p1 | Core regression | Daily CI |
| p2 | Full regression | Before release |
| p3 | Edge cases & error paths | Periodic execution |
Directory Structure
integration-tests/
├── config.yaml # Environment config (service addresses)
├── config.py # Global config singleton
├── pytest.ini # Mark registration, log format
├── run_tests.sh # Test runner entry point
├── services/
│ ├── api_client.py # Base HTTP client (BaseApiClient)
│ ├── gta_server.py # GTA Server API wrappers
│ └── gta_agent.py # GTA Agent API wrappers
└── tests/
├── base_test.py # Base test class (provides self.server / self.agent)
├── service_challenge/ # Server-side challenge test cases
└── collect_evidence/ # Agent evidence collection test cases
Adding Test Cases
Add to an existing module
Add a method to the relevant test class in the corresponding test_*.py file:
@pytest.mark.p1
def test_my_new_case(self):
"""P1: describe what this case verifies"""
resp = self.server.get_challenge(attester_type=["tpm_boot"])
assert resp.status_code == 200
Add a new module
-
Create a directory under
tests/and add__init__.py:tests/ └── my_feature/ ├── __init__.py └── test_my_feature.py -
Write a test class that inherits
BaseIntegrationTest:import pytest from tests.base_test import BaseIntegrationTest class TestMyFeature(BaseIntegrationTest): __test__ = True @pytest.mark.p0 def test_basic(self): """P0: description""" resp = self.server.some_api() assert resp.status_code == 200__test__ = Trueis required. The base class sets__test__ = Falseto prevent pytest from collecting it directly. -
If you need to call an endpoint not yet wrapped in
GtaServerService/GtaAgentService, use the underlying HTTP methods directly:resp = self.server.post("/global-trust-authority/service/v1/some-path", json={...}) resp = self.agent.get("/global-trust-authority/agent/v1/some-path") -
If the endpoint will be reused across multiple tests, wrap it as a method in
services/gta_server.pyorservices/gta_agent.py.