libtea 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {libtea-0.2.0 → libtea-0.4.0}/PKG-INFO +180 -11
  2. {libtea-0.2.0 → libtea-0.4.0}/README.md +176 -10
  3. libtea-0.4.0/libtea.cdx.json +1 -0
  4. {libtea-0.2.0 → libtea-0.4.0}/pyproject.toml +23 -3
  5. libtea-0.4.0/src/libtea/__init__.py +298 -0
  6. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_cli_fmt.py +57 -10
  7. libtea-0.4.0/src/libtea/_constants.py +14 -0
  8. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_hashing.py +2 -0
  9. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_http.py +76 -31
  10. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_security.py +20 -5
  11. libtea-0.4.0/src/libtea/cli.py +806 -0
  12. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/client.py +217 -9
  13. libtea-0.4.0/src/libtea/conformance/__init__.py +44 -0
  14. libtea-0.4.0/src/libtea/conformance/_checks.py +543 -0
  15. libtea-0.4.0/src/libtea/conformance/_runner.py +68 -0
  16. libtea-0.4.0/src/libtea/conformance/_types.py +42 -0
  17. libtea-0.4.0/src/libtea/conformance/plugin.py +112 -0
  18. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/discovery.py +129 -13
  19. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/models.py +43 -13
  20. libtea-0.4.0/src/libtea/protocols.py +151 -0
  21. libtea-0.4.0/src/libtea/server.py +28 -0
  22. libtea-0.2.0/.github/dependabot.yml +0 -18
  23. libtea-0.2.0/.github/workflows/ci.yaml +0 -22
  24. libtea-0.2.0/.github/workflows/codeql.yaml +0 -30
  25. libtea-0.2.0/.github/workflows/pypi.yaml +0 -65
  26. libtea-0.2.0/.pre-commit-config.yaml +0 -15
  27. libtea-0.2.0/CLAUDE.md +0 -93
  28. libtea-0.2.0/docs/FUTURE.md +0 -23
  29. libtea-0.2.0/docs/cli.md +0 -347
  30. libtea-0.2.0/docs/plans/2025-02-25-tea-client-design.md +0 -218
  31. libtea-0.2.0/docs/plans/2026-02-25-v0.2.0-design.md +0 -745
  32. libtea-0.2.0/docs/plans/2026-02-26-v0.3.0-design.md +0 -710
  33. libtea-0.2.0/src/libtea/__init__.py +0 -121
  34. libtea-0.2.0/src/libtea/cli.py +0 -623
  35. libtea-0.2.0/tests/__init__.py +0 -0
  36. libtea-0.2.0/tests/cli/__init__.py +0 -0
  37. libtea-0.2.0/tests/cli/test_cli.py +0 -1274
  38. libtea-0.2.0/tests/cli/test_cli_fmt.py +0 -953
  39. libtea-0.2.0/tests/client/__init__.py +0 -0
  40. libtea-0.2.0/tests/client/test_client.py +0 -762
  41. libtea-0.2.0/tests/client/test_discovery.py +0 -527
  42. libtea-0.2.0/tests/client/test_download.py +0 -120
  43. libtea-0.2.0/tests/client/test_http.py +0 -524
  44. libtea-0.2.0/tests/conftest.py +0 -25
  45. libtea-0.2.0/tests/integration/__init__.py +0 -0
  46. libtea-0.2.0/tests/integration/test_integration.py +0 -124
  47. libtea-0.2.0/tests/unit/__init__.py +0 -0
  48. libtea-0.2.0/tests/unit/test_cli_entry.py +0 -21
  49. libtea-0.2.0/tests/unit/test_exceptions.py +0 -75
  50. libtea-0.2.0/tests/unit/test_hashing.py +0 -60
  51. libtea-0.2.0/tests/unit/test_models.py +0 -581
  52. libtea-0.2.0/tests/unit/test_security.py +0 -198
  53. libtea-0.2.0/tests/unit/test_validation.py +0 -122
  54. libtea-0.2.0/tests/unit/test_version.py +0 -23
  55. libtea-0.2.0/uv.lock +0 -920
  56. {libtea-0.2.0 → libtea-0.4.0}/.gitignore +0 -0
  57. {libtea-0.2.0 → libtea-0.4.0}/LICENSE +0 -0
  58. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_cli_entry.py +0 -0
  59. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/_validation.py +0 -0
  60. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/exceptions.py +0 -0
  61. {libtea-0.2.0 → libtea-0.4.0}/src/libtea/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libtea
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Python client library for the Transparency Exchange API (TEA)
5
5
  Project-URL: Homepage, https://github.com/sbomify/py-libtea
6
6
  Project-URL: Repository, https://github.com/sbomify/py-libtea
@@ -28,6 +28,9 @@ Requires-Dist: semver<4,>=3.0.4
28
28
  Provides-Extra: cli
29
29
  Requires-Dist: click<9,>=8.0; extra == 'cli'
30
30
  Requires-Dist: rich>=13.0.0; extra == 'cli'
31
+ Provides-Extra: conformance
32
+ Requires-Dist: pytest>=8.0.0; extra == 'conformance'
33
+ Provides-Extra: server
31
34
  Description-Content-Type: text/markdown
32
35
 
33
36
  # libtea
@@ -36,6 +39,7 @@ Description-Content-Type: text/markdown
36
39
  [![PyPI version](https://img.shields.io/pypi/v/libtea.svg)](https://pypi.org/project/libtea/)
37
40
  [![Python](https://img.shields.io/pypi/pyversions/libtea.svg)](https://pypi.org/project/libtea/)
38
41
  [![License](https://img.shields.io/github/license/sbomify/py-libtea.svg)](https://github.com/sbomify/py-libtea/blob/master/LICENSE)
42
+ [![sbomified](https://sbomify.com/assets/images/logo/badge.svg)](https://trust.sbomify.com/component/py-libtea/)
39
43
 
40
44
  Python client library for the [Transparency Exchange API (TEA)](https://transparency.exchange/) v0.3.0-beta.2.
41
45
 
@@ -48,16 +52,25 @@ TEA is an open standard for discovering and retrieving software transparency art
48
52
  ### Features
49
53
 
50
54
  - Auto-discovery via `.well-known/tea` and TEI URNs
55
+ - Flexible version negotiation — connects to older server versions within the same major series
51
56
  - Products, components, releases, and versioned collections
52
57
  - Search by PURL, CPE, or TEI identifier
58
+ - Pagination auto-iterators for search results
59
+ - Bulk parallel fetch for products, releases, and artifacts
53
60
  - Common Lifecycle Enumeration (CLE) — ECMA-428 lifecycle events
54
61
  - Artifact download with on-the-fly checksum verification (MD5 through BLAKE2b)
62
+ - Optional TTL response caching
55
63
  - Endpoint failover with SemVer-compatible version selection
64
+ - SSRF protection — blocks private IPs, cloud metadata endpoints, DNS rebinding
56
65
  - Bearer token and HTTP basic auth authentication
57
66
  - Bearer token isolation — tokens are never sent to artifact download hosts
67
+ - `TeaClientProtocol` for dependency inversion and test doubles
58
68
  - Typed Pydantic v2 models with full camelCase/snake_case conversion
59
69
  - Structured exception hierarchy with error context
60
- - CLI with rich-formatted output and JSON mode
70
+ - CLI with rich-formatted output, JSON mode, and verbose logging
71
+ - Conformance test suite for validating TEA server compliance (programmatic, CLI, and pytest plugin)
72
+ - Server-side helpers (`tea_datetime_serializer`) for TEA API implementations
73
+ - Unfiltered listing endpoints (`list_products`, `list_product_releases`)
61
74
 
62
75
  ## Installation
63
76
 
@@ -71,13 +84,19 @@ To include the CLI (`tea-cli`):
71
84
  pip install libtea[cli]
72
85
  ```
73
86
 
87
+ To run conformance tests against a TEA server:
88
+
89
+ ```bash
90
+ pip install libtea[conformance]
91
+ ```
92
+
74
93
  ## Quick start
75
94
 
76
95
  ```python
77
96
  from libtea import TeaClient
78
97
 
79
98
  # Auto-discover the sbomify TEA server from its .well-known/tea
80
- with TeaClient.from_well_known("trust.sbomify.com", token="your-bearer-token") as client:
99
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
81
100
  # Discover a product by TEI
82
101
  results = client.discover(
83
102
  "urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
@@ -95,7 +114,6 @@ Or connect directly to a known endpoint:
95
114
  ```python
96
115
  client = TeaClient(
97
116
  base_url="https://trust.sbomify.com/tea/v0.3.0-beta.2",
98
- token="your-bearer-token",
99
117
  timeout=30.0,
100
118
  )
101
119
  ```
@@ -105,7 +123,6 @@ Using `from_well_known`, you can also override the spec version and timeout:
105
123
  ```python
106
124
  client = TeaClient.from_well_known(
107
125
  "trust.sbomify.com",
108
- token="your-bearer-token",
109
126
  timeout=15.0,
110
127
  version="0.3.0-beta.2", # default
111
128
  )
@@ -162,6 +179,52 @@ with TeaClient.from_well_known("trust.sbomify.com") as client:
162
179
  print(releases.total_results)
163
180
  ```
164
181
 
182
+ ### Listing (unfiltered)
183
+
184
+ ```python
185
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
186
+ # List all products (no identifier filter)
187
+ products = client.list_products(page_size=50)
188
+ for product in products.results:
189
+ print(product.name, product.uuid)
190
+
191
+ # List all product releases
192
+ releases = client.list_product_releases(page_size=50)
193
+ print(releases.total_results)
194
+ ```
195
+
196
+ ### Auto-paginated iterators
197
+
198
+ For iterating over large result sets without manual page management:
199
+
200
+ ```python
201
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
202
+ # Iterate all matching products (handles pagination automatically)
203
+ for product in client.iter_products("PURL", "pkg:github/sbomify/sbomify"):
204
+ print(product.name)
205
+
206
+ # Iterate all product releases by identifier
207
+ for release in client.iter_product_releases("PURL", "pkg:github/sbomify/sbomify"):
208
+ print(release.version)
209
+
210
+ # Iterate all releases for a specific product UUID
211
+ for release in client.iter_releases_for_product("product-uuid"):
212
+ print(release.version, release.created_date)
213
+ ```
214
+
215
+ ### Bulk parallel fetch
216
+
217
+ Fetch multiple resources by UUID in parallel:
218
+
219
+ ```python
220
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
221
+ products = client.get_products(["uuid-1", "uuid-2", "uuid-3"])
222
+ releases = client.get_product_releases_bulk(["uuid-1", "uuid-2"])
223
+ artifacts = client.get_artifacts(["uuid-1", "uuid-2"])
224
+ ```
225
+
226
+ Results are returned in the same order as the input UUIDs. Use `max_workers=1` for serial execution.
227
+
165
228
  ### Products and releases
166
229
 
167
230
  ```python
@@ -258,19 +321,67 @@ client = TeaClient.from_well_known("trust.sbomify.com", token="your-token")
258
321
  client = TeaClient.from_well_known("trust.sbomify.com", basic_auth=("user", "password"))
259
322
  ```
260
323
 
324
+ ### Response caching
325
+
326
+ Enable optional TTL-based caching to avoid repeated API calls:
327
+
328
+ ```python
329
+ # Cache GET responses for 5 minutes
330
+ client = TeaClient("https://trust.sbomify.com/tea/v0.3.0-beta.2", cache_ttl=300)
331
+ product = client.get_product("uuid") # HTTP call
332
+ product = client.get_product("uuid") # served from cache
333
+
334
+ client.clear_cache() # manually invalidate
335
+ ```
336
+
337
+ Only JSON API responses are cached — artifact downloads are never cached.
338
+
339
+ ### Private network access
340
+
341
+ By default, artifact downloads are blocked from private/internal IPs (SSRF protection). For local development:
342
+
343
+ ```python
344
+ client = TeaClient.from_well_known(
345
+ "trust.local",
346
+ scheme="http",
347
+ allow_private_ips=True, # allows downloads from 127.0.0.1, 10.x, etc.
348
+ )
349
+ ```
350
+
351
+ Scheme validation and cloud metadata endpoint blocking are always enforced.
352
+
353
+ ### Testing with TeaClientProtocol
354
+
355
+ Use the `TeaClientProtocol` for dependency inversion in consumer code:
356
+
357
+ ```python
358
+ from libtea import TeaClientProtocol
359
+
360
+ def fetch_sbom(client: TeaClientProtocol, product_uuid: str):
361
+ """Accepts any object matching the TeaClient interface."""
362
+ product = client.get_product(product_uuid)
363
+ return product.name
364
+ ```
365
+
366
+ This allows using mock objects in tests without depending on the concrete `TeaClient` class.
367
+
261
368
  ## CLI
262
369
 
263
370
  The `tea-cli` command provides a terminal interface for all TEA operations. Install with `pip install libtea[cli]`. See the [full CLI reference](docs/cli.md) for detailed documentation.
264
371
 
265
372
  ### Global options
266
373
 
374
+ These flags can be placed before or after the subcommand name. They appear under each subcommand's `--help` output.
375
+
267
376
  ```
268
- --json Output raw JSON instead of rich-formatted tables
269
- --debug, -d Show debug output (HTTP requests, timing)
270
- --version Show version
377
+ --json Output raw JSON instead of rich-formatted tables
378
+ --verbose, -v Show verbose output (libtea debug logs)
379
+ --debug, -d Show debug output (full HTTP firehose including urllib3)
380
+ --allow-private-ips Allow artifact downloads from private/internal IPs
381
+ --version Show version
271
382
  ```
272
383
 
273
- All commands accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
384
+ All commands also accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
274
385
 
275
386
  ### Discover
276
387
 
@@ -364,6 +475,19 @@ tea-cli get-cle <uuid> --entity component --domain trust.sbomify.com
364
475
  tea-cli get-cle <uuid> --entity component-release --domain trust.sbomify.com
365
476
  ```
366
477
 
478
+ ### Conformance
479
+
480
+ ```bash
481
+ # Run conformance checks against a TEA server
482
+ tea-cli conformance --base-url https://tea.example.com/v1
483
+
484
+ # With TEI for discovery-driven testing
485
+ tea-cli conformance --base-url https://tea.example.com/v1 --tei "urn:tei:..."
486
+
487
+ # JSON output for CI pipelines
488
+ tea-cli conformance --base-url https://tea.example.com/v1 --json
489
+ ```
490
+
367
491
  ### Environment variables
368
492
 
369
493
  | Variable | Description |
@@ -385,6 +509,49 @@ eval "$(_TEA_CLI_COMPLETE=zsh_source tea-cli)"
385
509
  _TEA_CLI_COMPLETE=fish_source tea-cli | source
386
510
  ```
387
511
 
512
+ ## Conformance testing
513
+
514
+ The conformance suite validates that a TEA server correctly implements the specification. It runs 26 checks covering discovery, products, releases, components, artifacts, CLE, and cross-cutting concerns (UUID format, pagination, camelCase).
515
+
516
+ ### Programmatic
517
+
518
+ ```python
519
+ from libtea.conformance import run_conformance
520
+
521
+ result = run_conformance(
522
+ "https://tea.example.com/v1",
523
+ tei="urn:tei:purl:example.com:pkg:pypi/mylib",
524
+ )
525
+ print(f"{result.passed} passed, {result.failed} failed, {result.skipped} skipped")
526
+ ```
527
+
528
+ ### CLI
529
+
530
+ ```bash
531
+ tea-cli conformance --base-url https://tea.example.com/v1 --tei "urn:tei:..."
532
+ tea-cli conformance --base-url https://tea.example.com/v1 --json
533
+ ```
534
+
535
+ ### pytest plugin
536
+
537
+ ```bash
538
+ pytest --tea-base-url https://tea.example.com/v1 --tea-tei "urn:tei:..."
539
+ ```
540
+
541
+ The plugin generates one test per conformance check. See the [conformance docs](docs/conformance.md) for the full check reference.
542
+
543
+ ## Server helpers
544
+
545
+ For TEA server implementations that use libtea models as response schemas:
546
+
547
+ ```python
548
+ from datetime import datetime, timezone
549
+ from libtea.server import tea_datetime_serializer
550
+
551
+ # Serialize to TEA spec format: "2024-03-20T15:30:00Z"
552
+ tea_datetime_serializer(datetime.now(timezone.utc))
553
+ ```
554
+
388
555
  ## Error handling
389
556
 
390
557
  All exceptions inherit from `TeaError`:
@@ -423,12 +590,14 @@ Using a bearer token over plaintext HTTP raises `ValueError` immediately — HTT
423
590
  - [Pydantic](https://docs.pydantic.dev/) >= 2.1.0 for data models
424
591
  - [semver](https://python-semver.readthedocs.io/) >= 3.0.4 for version selection
425
592
 
426
- Optional (for CLI): [click](https://click.palletsprojects.com/) >= 8.0, [rich](https://rich.readthedocs.io/) >= 13.0.0
593
+ Optional:
594
+ - CLI: [click](https://click.palletsprojects.com/) >= 8.0, [rich](https://rich.readthedocs.io/) >= 13.0.0
595
+ - Conformance: [pytest](https://docs.pytest.org/) >= 8.0.0
427
596
 
428
597
  ## Not yet supported
429
598
 
430
599
  - Publisher API (spec is consumer-only in beta.2)
431
- - Async client (httpx migration)
600
+ - Async client
432
601
 
433
602
  ## Development
434
603
 
@@ -4,6 +4,7 @@
4
4
  [![PyPI version](https://img.shields.io/pypi/v/libtea.svg)](https://pypi.org/project/libtea/)
5
5
  [![Python](https://img.shields.io/pypi/pyversions/libtea.svg)](https://pypi.org/project/libtea/)
6
6
  [![License](https://img.shields.io/github/license/sbomify/py-libtea.svg)](https://github.com/sbomify/py-libtea/blob/master/LICENSE)
7
+ [![sbomified](https://sbomify.com/assets/images/logo/badge.svg)](https://trust.sbomify.com/component/py-libtea/)
7
8
 
8
9
  Python client library for the [Transparency Exchange API (TEA)](https://transparency.exchange/) v0.3.0-beta.2.
9
10
 
@@ -16,16 +17,25 @@ TEA is an open standard for discovering and retrieving software transparency art
16
17
  ### Features
17
18
 
18
19
  - Auto-discovery via `.well-known/tea` and TEI URNs
20
+ - Flexible version negotiation — connects to older server versions within the same major series
19
21
  - Products, components, releases, and versioned collections
20
22
  - Search by PURL, CPE, or TEI identifier
23
+ - Pagination auto-iterators for search results
24
+ - Bulk parallel fetch for products, releases, and artifacts
21
25
  - Common Lifecycle Enumeration (CLE) — ECMA-428 lifecycle events
22
26
  - Artifact download with on-the-fly checksum verification (MD5 through BLAKE2b)
27
+ - Optional TTL response caching
23
28
  - Endpoint failover with SemVer-compatible version selection
29
+ - SSRF protection — blocks private IPs, cloud metadata endpoints, DNS rebinding
24
30
  - Bearer token and HTTP basic auth authentication
25
31
  - Bearer token isolation — tokens are never sent to artifact download hosts
32
+ - `TeaClientProtocol` for dependency inversion and test doubles
26
33
  - Typed Pydantic v2 models with full camelCase/snake_case conversion
27
34
  - Structured exception hierarchy with error context
28
- - CLI with rich-formatted output and JSON mode
35
+ - CLI with rich-formatted output, JSON mode, and verbose logging
36
+ - Conformance test suite for validating TEA server compliance (programmatic, CLI, and pytest plugin)
37
+ - Server-side helpers (`tea_datetime_serializer`) for TEA API implementations
38
+ - Unfiltered listing endpoints (`list_products`, `list_product_releases`)
29
39
 
30
40
  ## Installation
31
41
 
@@ -39,13 +49,19 @@ To include the CLI (`tea-cli`):
39
49
  pip install libtea[cli]
40
50
  ```
41
51
 
52
+ To run conformance tests against a TEA server:
53
+
54
+ ```bash
55
+ pip install libtea[conformance]
56
+ ```
57
+
42
58
  ## Quick start
43
59
 
44
60
  ```python
45
61
  from libtea import TeaClient
46
62
 
47
63
  # Auto-discover the sbomify TEA server from its .well-known/tea
48
- with TeaClient.from_well_known("trust.sbomify.com", token="your-bearer-token") as client:
64
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
49
65
  # Discover a product by TEI
50
66
  results = client.discover(
51
67
  "urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
@@ -63,7 +79,6 @@ Or connect directly to a known endpoint:
63
79
  ```python
64
80
  client = TeaClient(
65
81
  base_url="https://trust.sbomify.com/tea/v0.3.0-beta.2",
66
- token="your-bearer-token",
67
82
  timeout=30.0,
68
83
  )
69
84
  ```
@@ -73,7 +88,6 @@ Using `from_well_known`, you can also override the spec version and timeout:
73
88
  ```python
74
89
  client = TeaClient.from_well_known(
75
90
  "trust.sbomify.com",
76
- token="your-bearer-token",
77
91
  timeout=15.0,
78
92
  version="0.3.0-beta.2", # default
79
93
  )
@@ -130,6 +144,52 @@ with TeaClient.from_well_known("trust.sbomify.com") as client:
130
144
  print(releases.total_results)
131
145
  ```
132
146
 
147
+ ### Listing (unfiltered)
148
+
149
+ ```python
150
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
151
+ # List all products (no identifier filter)
152
+ products = client.list_products(page_size=50)
153
+ for product in products.results:
154
+ print(product.name, product.uuid)
155
+
156
+ # List all product releases
157
+ releases = client.list_product_releases(page_size=50)
158
+ print(releases.total_results)
159
+ ```
160
+
161
+ ### Auto-paginated iterators
162
+
163
+ For iterating over large result sets without manual page management:
164
+
165
+ ```python
166
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
167
+ # Iterate all matching products (handles pagination automatically)
168
+ for product in client.iter_products("PURL", "pkg:github/sbomify/sbomify"):
169
+ print(product.name)
170
+
171
+ # Iterate all product releases by identifier
172
+ for release in client.iter_product_releases("PURL", "pkg:github/sbomify/sbomify"):
173
+ print(release.version)
174
+
175
+ # Iterate all releases for a specific product UUID
176
+ for release in client.iter_releases_for_product("product-uuid"):
177
+ print(release.version, release.created_date)
178
+ ```
179
+
180
+ ### Bulk parallel fetch
181
+
182
+ Fetch multiple resources by UUID in parallel:
183
+
184
+ ```python
185
+ with TeaClient.from_well_known("trust.sbomify.com") as client:
186
+ products = client.get_products(["uuid-1", "uuid-2", "uuid-3"])
187
+ releases = client.get_product_releases_bulk(["uuid-1", "uuid-2"])
188
+ artifacts = client.get_artifacts(["uuid-1", "uuid-2"])
189
+ ```
190
+
191
+ Results are returned in the same order as the input UUIDs. Use `max_workers=1` for serial execution.
192
+
133
193
  ### Products and releases
134
194
 
135
195
  ```python
@@ -226,19 +286,67 @@ client = TeaClient.from_well_known("trust.sbomify.com", token="your-token")
226
286
  client = TeaClient.from_well_known("trust.sbomify.com", basic_auth=("user", "password"))
227
287
  ```
228
288
 
289
+ ### Response caching
290
+
291
+ Enable optional TTL-based caching to avoid repeated API calls:
292
+
293
+ ```python
294
+ # Cache GET responses for 5 minutes
295
+ client = TeaClient("https://trust.sbomify.com/tea/v0.3.0-beta.2", cache_ttl=300)
296
+ product = client.get_product("uuid") # HTTP call
297
+ product = client.get_product("uuid") # served from cache
298
+
299
+ client.clear_cache() # manually invalidate
300
+ ```
301
+
302
+ Only JSON API responses are cached — artifact downloads are never cached.
303
+
304
+ ### Private network access
305
+
306
+ By default, artifact downloads are blocked from private/internal IPs (SSRF protection). For local development:
307
+
308
+ ```python
309
+ client = TeaClient.from_well_known(
310
+ "trust.local",
311
+ scheme="http",
312
+ allow_private_ips=True, # allows downloads from 127.0.0.1, 10.x, etc.
313
+ )
314
+ ```
315
+
316
+ Scheme validation and cloud metadata endpoint blocking are always enforced.
317
+
318
+ ### Testing with TeaClientProtocol
319
+
320
+ Use the `TeaClientProtocol` for dependency inversion in consumer code:
321
+
322
+ ```python
323
+ from libtea import TeaClientProtocol
324
+
325
+ def fetch_sbom(client: TeaClientProtocol, product_uuid: str):
326
+ """Accepts any object matching the TeaClient interface."""
327
+ product = client.get_product(product_uuid)
328
+ return product.name
329
+ ```
330
+
331
+ This allows using mock objects in tests without depending on the concrete `TeaClient` class.
332
+
229
333
  ## CLI
230
334
 
231
335
  The `tea-cli` command provides a terminal interface for all TEA operations. Install with `pip install libtea[cli]`. See the [full CLI reference](docs/cli.md) for detailed documentation.
232
336
 
233
337
  ### Global options
234
338
 
339
+ These flags can be placed before or after the subcommand name. They appear under each subcommand's `--help` output.
340
+
235
341
  ```
236
- --json Output raw JSON instead of rich-formatted tables
237
- --debug, -d Show debug output (HTTP requests, timing)
238
- --version Show version
342
+ --json Output raw JSON instead of rich-formatted tables
343
+ --verbose, -v Show verbose output (libtea debug logs)
344
+ --debug, -d Show debug output (full HTTP firehose including urllib3)
345
+ --allow-private-ips Allow artifact downloads from private/internal IPs
346
+ --version Show version
239
347
  ```
240
348
 
241
- All commands accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
349
+ All commands also accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
242
350
 
243
351
  ### Discover
244
352
 
@@ -332,6 +440,19 @@ tea-cli get-cle <uuid> --entity component --domain trust.sbomify.com
332
440
  tea-cli get-cle <uuid> --entity component-release --domain trust.sbomify.com
333
441
  ```
334
442
 
443
+ ### Conformance
444
+
445
+ ```bash
446
+ # Run conformance checks against a TEA server
447
+ tea-cli conformance --base-url https://tea.example.com/v1
448
+
449
+ # With TEI for discovery-driven testing
450
+ tea-cli conformance --base-url https://tea.example.com/v1 --tei "urn:tei:..."
451
+
452
+ # JSON output for CI pipelines
453
+ tea-cli conformance --base-url https://tea.example.com/v1 --json
454
+ ```
455
+
335
456
  ### Environment variables
336
457
 
337
458
  | Variable | Description |
@@ -353,6 +474,49 @@ eval "$(_TEA_CLI_COMPLETE=zsh_source tea-cli)"
353
474
  _TEA_CLI_COMPLETE=fish_source tea-cli | source
354
475
  ```
355
476
 
477
+ ## Conformance testing
478
+
479
+ The conformance suite validates that a TEA server correctly implements the specification. It runs 26 checks covering discovery, products, releases, components, artifacts, CLE, and cross-cutting concerns (UUID format, pagination, camelCase).
480
+
481
+ ### Programmatic
482
+
483
+ ```python
484
+ from libtea.conformance import run_conformance
485
+
486
+ result = run_conformance(
487
+ "https://tea.example.com/v1",
488
+ tei="urn:tei:purl:example.com:pkg:pypi/mylib",
489
+ )
490
+ print(f"{result.passed} passed, {result.failed} failed, {result.skipped} skipped")
491
+ ```
492
+
493
+ ### CLI
494
+
495
+ ```bash
496
+ tea-cli conformance --base-url https://tea.example.com/v1 --tei "urn:tei:..."
497
+ tea-cli conformance --base-url https://tea.example.com/v1 --json
498
+ ```
499
+
500
+ ### pytest plugin
501
+
502
+ ```bash
503
+ pytest --tea-base-url https://tea.example.com/v1 --tea-tei "urn:tei:..."
504
+ ```
505
+
506
+ The plugin generates one test per conformance check. See the [conformance docs](docs/conformance.md) for the full check reference.
507
+
508
+ ## Server helpers
509
+
510
+ For TEA server implementations that use libtea models as response schemas:
511
+
512
+ ```python
513
+ from datetime import datetime, timezone
514
+ from libtea.server import tea_datetime_serializer
515
+
516
+ # Serialize to TEA spec format: "2024-03-20T15:30:00Z"
517
+ tea_datetime_serializer(datetime.now(timezone.utc))
518
+ ```
519
+
356
520
  ## Error handling
357
521
 
358
522
  All exceptions inherit from `TeaError`:
@@ -391,12 +555,14 @@ Using a bearer token over plaintext HTTP raises `ValueError` immediately — HTT
391
555
  - [Pydantic](https://docs.pydantic.dev/) >= 2.1.0 for data models
392
556
  - [semver](https://python-semver.readthedocs.io/) >= 3.0.4 for version selection
393
557
 
394
- Optional (for CLI): [click](https://click.palletsprojects.com/) >= 8.0, [rich](https://rich.readthedocs.io/) >= 13.0.0
558
+ Optional:
559
+ - CLI: [click](https://click.palletsprojects.com/) >= 8.0, [rich](https://rich.readthedocs.io/) >= 13.0.0
560
+ - Conformance: [pytest](https://docs.pytest.org/) >= 8.0.0
395
561
 
396
562
  ## Not yet supported
397
563
 
398
564
  - Publisher API (spec is consumer-only in beta.2)
399
- - Async client (httpx migration)
565
+ - Async client
400
566
 
401
567
  ## Development
402
568