colibri-artifacts 0.1.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.
@@ -0,0 +1 @@
1
+ exclude tests/test_artifacts.py
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.4
2
+ Name: colibri-artifacts
3
+ Version: 0.1.0
4
+ Summary: Command-line client for the Colibri Artifacts repository
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: httpx<1,>=0.27
8
+ Provides-Extra: publish
9
+ Requires-Dist: build<2,>=1.2; extra == "publish"
10
+ Requires-Dist: twine<7,>=6; extra == "publish"
11
+
12
+ # Colibri Artifacts
13
+
14
+ A command-line client and a separate HTTP server for arbitrary files,
15
+ not a package manager. **Only the client is intended for PyPI.** Installing the
16
+ client does not install or run the server.
17
+
18
+ An artifact is identified by **project + version**. Only one file can be uploaded
19
+ for each pair. The original filename is preserved and returned when downloading,
20
+ but is not used to look up the artifact.
21
+ `latest` means the project's most recently uploaded version, not the highest
22
+ SemVer version. Uploading an existing version is rejected; there are no API
23
+ methods to delete or modify artifacts.
24
+
25
+ ## Client installation
26
+
27
+ Requires Python 3.10+. To install the client from the repository root:
28
+
29
+ ```bash
30
+ python3 -m venv .venv
31
+ . .venv/bin/activate
32
+ pip install .
33
+ colibri-artifacts --help
34
+ ```
35
+
36
+ After the client has been published to PyPI, installation will be:
37
+
38
+ ```bash
39
+ pip install colibri-artifacts
40
+ ```
41
+
42
+ The package has **not been published yet**, and availability of the package
43
+ name has not been checked. Until then, install from source or a built wheel.
44
+ You can also run the client with `python -m colibri_artifacts`.
45
+
46
+ ### Configure the server
47
+
48
+ The client connects to `http://127.0.0.1:8000` by default. To use your server:
49
+
50
+ ```bash
51
+ export ARTIFACTS_URL=http://artifacts.internal:8000
52
+ ```
53
+
54
+ Alternatively, pass `--server` **before the subcommand**. It overrides
55
+ `ARTIFACTS_URL` for that invocation:
56
+
57
+ ```bash
58
+ colibri-artifacts --server http://artifacts.internal:8000 download my-service
59
+ ```
60
+
61
+ HTTP and HTTPS URLs are supported, including reverse proxy path prefixes such
62
+ as `https://artifacts.example.com/repository/`. TLS certificates are verified.
63
+ The client uses a 60-second timeout for network inactivity, not for the total
64
+ transfer duration.
65
+
66
+ ### Upload a file
67
+
68
+ ```bash
69
+ colibri-artifacts upload my-service 2026.11.26 ./build.tar.gz
70
+ ```
71
+
72
+ Arguments are `PROJECT VERSION FILE`. The client sends the file as multipart
73
+ form data, using its local basename as the original filename. It prints the
74
+ server's JSON metadata on success. A project does not need to be created first.
75
+ An existing project/version pair cannot be overwritten, even with identical
76
+ contents. `latest` is not a valid upload version.
77
+
78
+ ### Download a file
79
+
80
+ ```bash
81
+ # Download a specific version using the original filename in the current directory.
82
+ colibri-artifacts download my-service 2026.11.26
83
+
84
+ # Download the latest version; omitting VERSION also means latest.
85
+ colibri-artifacts download my-service latest
86
+ colibri-artifacts download my-service
87
+
88
+ # Choose a destination filename.
89
+ colibri-artifacts download my-service latest --output ./release.tar.gz
90
+ ```
91
+
92
+ Arguments are `PROJECT [VERSION]`; `-o` is an alias for `--output`.
93
+ The destination must not already exist, and its parent directory must exist.
94
+ Downloads are streamed to disk and verified against the server's SHA-256
95
+ checksum. A failed transfer or checksum mismatch removes the newly created
96
+ partial file. Existing local files are never overwritten.
97
+ Unsafe or missing server filenames are rejected unless an explicit output
98
+ path is supplied. On success, the client prints the destination path.
99
+
100
+ ### Errors and automation
101
+
102
+ Successful commands exit with code `0`. Network, HTTP, local filesystem,
103
+ response parsing, and checksum errors are written to stderr and exit with code
104
+ `1`. Invalid command-line arguments exit with code `2`.
105
+ Use an explicit version for reproducible CI jobs; `latest` changes when a new
106
+ version is successfully uploaded.
107
+
108
+ ## Server deployment
109
+
110
+ The server is separate from the client. It is installed from `server/` for
111
+ deployment or built into the Docker image; it is **not intended for PyPI**.
112
+ Requires Python 3.10+ and Linux with a local filesystem.
113
+ From the repository root, in a server-side virtual environment:
114
+
115
+ ```bash
116
+ pip install ./server
117
+ colibri-artifacts-server --storage /mnt/artifacts --host 127.0.0.1 --port 8000
118
+ ```
119
+
120
+ You can also run `python -m colibri_artifacts_server`.
121
+ The storage directory is created automatically; the process user must have
122
+ write permission. Instead of `--storage`, you can set the `ARTIFACTS_STORAGE`
123
+ environment variable (default: `./data`).
124
+ By default, the server listens only on `127.0.0.1:8000`.
125
+ Interactive API documentation: <http://127.0.0.1:8000/docs>.
126
+
127
+ **There is no authentication.** Anyone with access to the server can download
128
+ files and claim new versions, including by uploading arbitrary amounts of data.
129
+ Do not expose the port to the Internet; use a trusted network, firewall, or
130
+ reverse proxy with TLS, authentication, and request size limits.
131
+ To allow access from a trusted network, explicitly set `--host 0.0.0.0`.
132
+
133
+ ## HTTP API
134
+
135
+ The client wraps these endpoints; direct HTTP access is also supported.
136
+
137
+ Project and version identifiers must be 1–128 ASCII characters. The first
138
+ character must be a letter or digit; subsequent characters may also include
139
+ `.`, `_`, and `-`. Identifiers are case-sensitive.
140
+ `latest` is reserved and cannot be used for uploads.
141
+
142
+ ```bash
143
+ # Upload: multipart field named "file"; version can be any string in the format above.
144
+ curl --fail-with-body \
145
+ -F 'file=@./build.tar.gz' \
146
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
147
+
148
+ # Download a specific version, keeping the original filename.
149
+ curl --fail -OJ \
150
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
151
+
152
+ # Download the project's most recently uploaded version.
153
+ curl --fail -OJ \
154
+ http://127.0.0.1:8000/projects/my-service/versions/latest
155
+ ```
156
+
157
+ An upload returns `201` with `project`, `version`, `filename`, `size` in bytes,
158
+ and `sha256`. An existing version returns `409`, a missing artifact returns
159
+ `404`, an invalid request returns `422`, and delete or modification requests
160
+ return `405`. Path separators and control characters are not allowed in the
161
+ original filename.
162
+
163
+ Downloads include `Content-Disposition: attachment`, `X-Artifact-Version`,
164
+ `X-Checksum-SHA256`, and an `ETag` containing the SHA-256 checksum.
165
+ Responses for `latest` are not cached; specific immutable versions can be
166
+ cached. If uploads happen concurrently, `latest` is determined by the order in
167
+ which they are committed to the catalog.
168
+
169
+ ## Storage and durability
170
+
171
+ The `--storage` directory contains the SQLite catalog, `catalog.sqlite3`, and
172
+ the `objects` directory holding file contents. Stored objects have random
173
+ internal names; the original filename, including Unicode characters, is kept
174
+ in the catalog. Keep the entire storage directory on persistent storage or a
175
+ bind mount. Restarting the server does not change its contents.
176
+
177
+ An upload is first written to a temporary file and synced to disk. The object is
178
+ published without overwriting an existing file, and the catalog record is
179
+ committed in a transaction. Concurrent uploads of the same version result in
180
+ one success and conflicts for the others. A failed upload does not change
181
+ `latest`. Each operation uses its own SQLite connection; database locks
182
+ serialize upload commits.
183
+
184
+ This is **not WORM storage**: deletion is prevented through the HTTP API only.
185
+ An OS administrator or a process with write access to the disk can delete data.
186
+ Use separate storage protections and backups if stronger protection is needed.
187
+ After a crash, temporary or uncataloged objects may remain; they are not
188
+ accessible through the API. Objects are never deleted automatically.
189
+ For a consistent backup, stop the server and copy the **entire** storage
190
+ directory. Network filesystems (NFS/SMB) are not supported: this implementation
191
+ requires correct SQLite locking, hard links, and `fsync` on a local filesystem.
192
+ Multipart uploads may also use the system temporary directory, so ensure it
193
+ has enough free space or set `TMPDIR` before starting the process.
194
+
195
+ ## Docker Compose
196
+
197
+ The container runs as UID/GID `10001`. Prepare permissions for the bind mount:
198
+
199
+ ```bash
200
+ mkdir -p data
201
+ sudo chown 10001:10001 data
202
+ docker compose up -d --build
203
+ ```
204
+
205
+ Compose mounts `./data` at `/data` and publishes the port on localhost only.
206
+ To use a separate disk, replace `./data` with `/mnt/artifacts` in
207
+ `compose.yaml` and set permissions on that directory. For network access,
208
+ configure a reverse proxy or change the port binding while keeping appropriate
209
+ network restrictions.
210
+
211
+ ## Development and tests
212
+
213
+ Install both local packages to run the client tests, server tests, and their
214
+ integration test. This does not publish either package.
215
+
216
+ ```bash
217
+ pip install -e . -e ./server
218
+ python -m unittest discover -s tests -v
219
+ ```
220
+
221
+ To run only the client tests, the server package is not required:
222
+
223
+ ```bash
224
+ python -m unittest discover -s tests -p test_client.py -v
225
+ ```
226
+
227
+ ## Publishing the client to PyPI
228
+
229
+ Build and upload **only the root project**, not `server/`.
230
+ The root distribution contains the client and depends on HTTPX, not FastAPI,
231
+ Uvicorn, or the server package. The server distribution is marked
232
+ `Private :: Do Not Upload` to prevent accidental uploads to PyPI.
233
+
234
+ The client package is prepared for publishing but **has not been published**.
235
+ The name `colibri-artifacts` is provisional; its availability has not been
236
+ checked. Before publishing publicly, choose a license, add it to the project,
237
+ and make sure you are allowed to publish the repository's contents.
238
+ If the name is taken, change `project.name` in `pyproject.toml`.
239
+
240
+ ```bash
241
+ pip install '.[publish]'
242
+ python -m build --outdir dist/client
243
+ python -m twine check dist/client/*
244
+ python -m twine upload dist/client/*
245
+ ```
246
+
247
+ Use a clean `dist/client` directory for each release, and increment the version
248
+ in the root `pyproject.toml` before publishing a new release. PyPI does not allow
249
+ replacing already published distributions.
250
+ Publishing requires your PyPI account and a token or Trusted Publishing.
251
+ Do not store the token in the repository. After publishing under the chosen name:
252
+
253
+ ```bash
254
+ pip install colibri-artifacts
255
+ ```
@@ -0,0 +1,244 @@
1
+ # Colibri Artifacts
2
+
3
+ A command-line client and a separate HTTP server for arbitrary files,
4
+ not a package manager. **Only the client is intended for PyPI.** Installing the
5
+ client does not install or run the server.
6
+
7
+ An artifact is identified by **project + version**. Only one file can be uploaded
8
+ for each pair. The original filename is preserved and returned when downloading,
9
+ but is not used to look up the artifact.
10
+ `latest` means the project's most recently uploaded version, not the highest
11
+ SemVer version. Uploading an existing version is rejected; there are no API
12
+ methods to delete or modify artifacts.
13
+
14
+ ## Client installation
15
+
16
+ Requires Python 3.10+. To install the client from the repository root:
17
+
18
+ ```bash
19
+ python3 -m venv .venv
20
+ . .venv/bin/activate
21
+ pip install .
22
+ colibri-artifacts --help
23
+ ```
24
+
25
+ After the client has been published to PyPI, installation will be:
26
+
27
+ ```bash
28
+ pip install colibri-artifacts
29
+ ```
30
+
31
+ The package has **not been published yet**, and availability of the package
32
+ name has not been checked. Until then, install from source or a built wheel.
33
+ You can also run the client with `python -m colibri_artifacts`.
34
+
35
+ ### Configure the server
36
+
37
+ The client connects to `http://127.0.0.1:8000` by default. To use your server:
38
+
39
+ ```bash
40
+ export ARTIFACTS_URL=http://artifacts.internal:8000
41
+ ```
42
+
43
+ Alternatively, pass `--server` **before the subcommand**. It overrides
44
+ `ARTIFACTS_URL` for that invocation:
45
+
46
+ ```bash
47
+ colibri-artifacts --server http://artifacts.internal:8000 download my-service
48
+ ```
49
+
50
+ HTTP and HTTPS URLs are supported, including reverse proxy path prefixes such
51
+ as `https://artifacts.example.com/repository/`. TLS certificates are verified.
52
+ The client uses a 60-second timeout for network inactivity, not for the total
53
+ transfer duration.
54
+
55
+ ### Upload a file
56
+
57
+ ```bash
58
+ colibri-artifacts upload my-service 2026.11.26 ./build.tar.gz
59
+ ```
60
+
61
+ Arguments are `PROJECT VERSION FILE`. The client sends the file as multipart
62
+ form data, using its local basename as the original filename. It prints the
63
+ server's JSON metadata on success. A project does not need to be created first.
64
+ An existing project/version pair cannot be overwritten, even with identical
65
+ contents. `latest` is not a valid upload version.
66
+
67
+ ### Download a file
68
+
69
+ ```bash
70
+ # Download a specific version using the original filename in the current directory.
71
+ colibri-artifacts download my-service 2026.11.26
72
+
73
+ # Download the latest version; omitting VERSION also means latest.
74
+ colibri-artifacts download my-service latest
75
+ colibri-artifacts download my-service
76
+
77
+ # Choose a destination filename.
78
+ colibri-artifacts download my-service latest --output ./release.tar.gz
79
+ ```
80
+
81
+ Arguments are `PROJECT [VERSION]`; `-o` is an alias for `--output`.
82
+ The destination must not already exist, and its parent directory must exist.
83
+ Downloads are streamed to disk and verified against the server's SHA-256
84
+ checksum. A failed transfer or checksum mismatch removes the newly created
85
+ partial file. Existing local files are never overwritten.
86
+ Unsafe or missing server filenames are rejected unless an explicit output
87
+ path is supplied. On success, the client prints the destination path.
88
+
89
+ ### Errors and automation
90
+
91
+ Successful commands exit with code `0`. Network, HTTP, local filesystem,
92
+ response parsing, and checksum errors are written to stderr and exit with code
93
+ `1`. Invalid command-line arguments exit with code `2`.
94
+ Use an explicit version for reproducible CI jobs; `latest` changes when a new
95
+ version is successfully uploaded.
96
+
97
+ ## Server deployment
98
+
99
+ The server is separate from the client. It is installed from `server/` for
100
+ deployment or built into the Docker image; it is **not intended for PyPI**.
101
+ Requires Python 3.10+ and Linux with a local filesystem.
102
+ From the repository root, in a server-side virtual environment:
103
+
104
+ ```bash
105
+ pip install ./server
106
+ colibri-artifacts-server --storage /mnt/artifacts --host 127.0.0.1 --port 8000
107
+ ```
108
+
109
+ You can also run `python -m colibri_artifacts_server`.
110
+ The storage directory is created automatically; the process user must have
111
+ write permission. Instead of `--storage`, you can set the `ARTIFACTS_STORAGE`
112
+ environment variable (default: `./data`).
113
+ By default, the server listens only on `127.0.0.1:8000`.
114
+ Interactive API documentation: <http://127.0.0.1:8000/docs>.
115
+
116
+ **There is no authentication.** Anyone with access to the server can download
117
+ files and claim new versions, including by uploading arbitrary amounts of data.
118
+ Do not expose the port to the Internet; use a trusted network, firewall, or
119
+ reverse proxy with TLS, authentication, and request size limits.
120
+ To allow access from a trusted network, explicitly set `--host 0.0.0.0`.
121
+
122
+ ## HTTP API
123
+
124
+ The client wraps these endpoints; direct HTTP access is also supported.
125
+
126
+ Project and version identifiers must be 1–128 ASCII characters. The first
127
+ character must be a letter or digit; subsequent characters may also include
128
+ `.`, `_`, and `-`. Identifiers are case-sensitive.
129
+ `latest` is reserved and cannot be used for uploads.
130
+
131
+ ```bash
132
+ # Upload: multipart field named "file"; version can be any string in the format above.
133
+ curl --fail-with-body \
134
+ -F 'file=@./build.tar.gz' \
135
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
136
+
137
+ # Download a specific version, keeping the original filename.
138
+ curl --fail -OJ \
139
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
140
+
141
+ # Download the project's most recently uploaded version.
142
+ curl --fail -OJ \
143
+ http://127.0.0.1:8000/projects/my-service/versions/latest
144
+ ```
145
+
146
+ An upload returns `201` with `project`, `version`, `filename`, `size` in bytes,
147
+ and `sha256`. An existing version returns `409`, a missing artifact returns
148
+ `404`, an invalid request returns `422`, and delete or modification requests
149
+ return `405`. Path separators and control characters are not allowed in the
150
+ original filename.
151
+
152
+ Downloads include `Content-Disposition: attachment`, `X-Artifact-Version`,
153
+ `X-Checksum-SHA256`, and an `ETag` containing the SHA-256 checksum.
154
+ Responses for `latest` are not cached; specific immutable versions can be
155
+ cached. If uploads happen concurrently, `latest` is determined by the order in
156
+ which they are committed to the catalog.
157
+
158
+ ## Storage and durability
159
+
160
+ The `--storage` directory contains the SQLite catalog, `catalog.sqlite3`, and
161
+ the `objects` directory holding file contents. Stored objects have random
162
+ internal names; the original filename, including Unicode characters, is kept
163
+ in the catalog. Keep the entire storage directory on persistent storage or a
164
+ bind mount. Restarting the server does not change its contents.
165
+
166
+ An upload is first written to a temporary file and synced to disk. The object is
167
+ published without overwriting an existing file, and the catalog record is
168
+ committed in a transaction. Concurrent uploads of the same version result in
169
+ one success and conflicts for the others. A failed upload does not change
170
+ `latest`. Each operation uses its own SQLite connection; database locks
171
+ serialize upload commits.
172
+
173
+ This is **not WORM storage**: deletion is prevented through the HTTP API only.
174
+ An OS administrator or a process with write access to the disk can delete data.
175
+ Use separate storage protections and backups if stronger protection is needed.
176
+ After a crash, temporary or uncataloged objects may remain; they are not
177
+ accessible through the API. Objects are never deleted automatically.
178
+ For a consistent backup, stop the server and copy the **entire** storage
179
+ directory. Network filesystems (NFS/SMB) are not supported: this implementation
180
+ requires correct SQLite locking, hard links, and `fsync` on a local filesystem.
181
+ Multipart uploads may also use the system temporary directory, so ensure it
182
+ has enough free space or set `TMPDIR` before starting the process.
183
+
184
+ ## Docker Compose
185
+
186
+ The container runs as UID/GID `10001`. Prepare permissions for the bind mount:
187
+
188
+ ```bash
189
+ mkdir -p data
190
+ sudo chown 10001:10001 data
191
+ docker compose up -d --build
192
+ ```
193
+
194
+ Compose mounts `./data` at `/data` and publishes the port on localhost only.
195
+ To use a separate disk, replace `./data` with `/mnt/artifacts` in
196
+ `compose.yaml` and set permissions on that directory. For network access,
197
+ configure a reverse proxy or change the port binding while keeping appropriate
198
+ network restrictions.
199
+
200
+ ## Development and tests
201
+
202
+ Install both local packages to run the client tests, server tests, and their
203
+ integration test. This does not publish either package.
204
+
205
+ ```bash
206
+ pip install -e . -e ./server
207
+ python -m unittest discover -s tests -v
208
+ ```
209
+
210
+ To run only the client tests, the server package is not required:
211
+
212
+ ```bash
213
+ python -m unittest discover -s tests -p test_client.py -v
214
+ ```
215
+
216
+ ## Publishing the client to PyPI
217
+
218
+ Build and upload **only the root project**, not `server/`.
219
+ The root distribution contains the client and depends on HTTPX, not FastAPI,
220
+ Uvicorn, or the server package. The server distribution is marked
221
+ `Private :: Do Not Upload` to prevent accidental uploads to PyPI.
222
+
223
+ The client package is prepared for publishing but **has not been published**.
224
+ The name `colibri-artifacts` is provisional; its availability has not been
225
+ checked. Before publishing publicly, choose a license, add it to the project,
226
+ and make sure you are allowed to publish the repository's contents.
227
+ If the name is taken, change `project.name` in `pyproject.toml`.
228
+
229
+ ```bash
230
+ pip install '.[publish]'
231
+ python -m build --outdir dist/client
232
+ python -m twine check dist/client/*
233
+ python -m twine upload dist/client/*
234
+ ```
235
+
236
+ Use a clean `dist/client` directory for each release, and increment the version
237
+ in the root `pyproject.toml` before publishing a new release. PyPI does not allow
238
+ replacing already published distributions.
239
+ Publishing requires your PyPI account and a token or Trusted Publishing.
240
+ Do not store the token in the repository. After publishing under the chosen name:
241
+
242
+ ```bash
243
+ pip install colibri-artifacts
244
+ ```
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "colibri-artifacts"
7
+ version = "0.1.0"
8
+ description = "Command-line client for the Colibri Artifacts repository"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = ["httpx>=0.27,<1"]
12
+
13
+ [project.optional-dependencies]
14
+ publish = ["build>=1.2,<2", "twine>=6,<7"]
15
+
16
+ [project.scripts]
17
+ colibri-artifacts = "colibri_artifacts.__main__:main"
18
+
19
+ [tool.setuptools.packages.find]
20
+ where = ["src"]
21
+ include = ["colibri_artifacts*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Command-line client for the Colibri Artifacts repository."""
@@ -0,0 +1,63 @@
1
+ import argparse
2
+ import json
3
+ import os
4
+ import re
5
+ from pathlib import Path
6
+
7
+ import httpx
8
+
9
+ from .client import ClientError, download, upload
10
+
11
+
12
+ def identifier(value: str) -> str:
13
+ if re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]{0,127}", value) is None:
14
+ raise argparse.ArgumentTypeError(
15
+ "use 1-128 ASCII letters, digits, dots, underscores or hyphens; start with a letter or digit"
16
+ )
17
+ return value
18
+
19
+
20
+ def server_url(value: str) -> str:
21
+ try:
22
+ url = httpx.URL(value)
23
+ except httpx.InvalidURL as error:
24
+ raise argparse.ArgumentTypeError(str(error)) from error
25
+ if url.scheme not in {"http", "https"} or not url.host or url.query or url.fragment:
26
+ raise argparse.ArgumentTypeError("use an HTTP(S) server URL without query or fragment")
27
+ return str(url).rstrip("/") + "/"
28
+
29
+
30
+ def main(argv: list[str] | None = None) -> None:
31
+ parser = argparse.ArgumentParser(description="Upload and download Colibri Artifacts")
32
+ parser.add_argument(
33
+ "--server",
34
+ type=server_url,
35
+ default=os.environ.get("ARTIFACTS_URL", "http://127.0.0.1:8000"),
36
+ help="server URL (default: ARTIFACTS_URL or http://127.0.0.1:8000)",
37
+ )
38
+ commands = parser.add_subparsers(dest="command", required=True)
39
+ upload_parser = commands.add_parser("upload", help="upload a new, immutable version")
40
+ upload_parser.add_argument("project", type=identifier)
41
+ upload_parser.add_argument("version", type=identifier)
42
+ upload_parser.add_argument("file", type=Path)
43
+ download_parser = commands.add_parser("download", help="download a version or latest")
44
+ download_parser.add_argument("project", type=identifier)
45
+ download_parser.add_argument("version", type=identifier, nargs="?", default="latest")
46
+ download_parser.add_argument("-o", "--output", type=Path, help="destination file (must not exist)")
47
+ args = parser.parse_args(argv)
48
+ if args.command == "upload" and args.version == "latest":
49
+ parser.error("'latest' is reserved for downloads")
50
+ try:
51
+ with httpx.Client(base_url=args.server, timeout=60) as client:
52
+ if args.command == "upload":
53
+ print(json.dumps(upload(client, args.project, args.version, args.file)))
54
+ else:
55
+ print(download(client, args.project, args.version, args.output))
56
+ except httpx.HTTPStatusError as error:
57
+ parser.exit(1, f"Error: HTTP {error.response.status_code}: {error.response.text}\n")
58
+ except (httpx.RequestError, OSError, ClientError, json.JSONDecodeError) as error:
59
+ parser.exit(1, f"Error: {error or type(error).__name__}\n")
60
+
61
+
62
+ if __name__ == "__main__":
63
+ main()
@@ -0,0 +1,73 @@
1
+ import hashlib
2
+ import re
3
+ from email.message import Message
4
+ from email.utils import collapse_rfc2231_value
5
+ from pathlib import Path
6
+
7
+ import httpx
8
+
9
+
10
+ class ClientError(Exception):
11
+ pass
12
+
13
+
14
+ def _check_response(response: httpx.Response) -> None:
15
+ if not response.is_success:
16
+ response.read()
17
+ response.raise_for_status()
18
+
19
+
20
+ def upload(client: httpx.Client, project: str, version: str, source: Path) -> dict[str, object]:
21
+ with source.open("rb") as file:
22
+ response = client.post(
23
+ f"projects/{project}/versions/{version}",
24
+ files={"file": (source.name, file, "application/octet-stream")},
25
+ )
26
+ _check_response(response)
27
+ result = response.json()
28
+ if not isinstance(result, dict):
29
+ raise ClientError("Expected a JSON object in the upload response")
30
+ return result
31
+
32
+
33
+ def _filename(response: httpx.Response) -> str:
34
+ message = Message()
35
+ message["Content-Disposition"] = response.headers.get("content-disposition", "")
36
+ parameter = message.get_param("filename", header="content-disposition")
37
+ filename = collapse_rfc2231_value(parameter) if parameter is not None else None
38
+ if (
39
+ not filename
40
+ or filename in {".", ".."}
41
+ or Path(filename).drive
42
+ or any(character in filename for character in ("/", "\\"))
43
+ or any(ord(character) < 32 or ord(character) == 127 for character in filename)
44
+ ):
45
+ raise ClientError("The server returned a missing or unsafe filename; use --output")
46
+ return filename
47
+
48
+
49
+ def download(
50
+ client: httpx.Client, project: str, version: str, destination: Path | None
51
+ ) -> Path:
52
+ with client.stream("GET", f"projects/{project}/versions/{version}") as response:
53
+ _check_response(response)
54
+ expected = response.headers.get("x-checksum-sha256", "")
55
+ if re.fullmatch(r"[0-9a-fA-F]{64}", expected) is None:
56
+ raise ClientError("The server returned a missing or invalid SHA-256 checksum")
57
+ target = destination if destination is not None else Path(_filename(response))
58
+ digest = hashlib.sha256()
59
+ created = False
60
+ verified = False
61
+ try:
62
+ with target.open("xb") as output:
63
+ created = True
64
+ for chunk in response.iter_bytes(chunk_size=1024 * 1024):
65
+ output.write(chunk)
66
+ digest.update(chunk)
67
+ if digest.hexdigest() != expected.lower():
68
+ raise ClientError("SHA-256 mismatch; the incomplete download has been removed")
69
+ verified = True
70
+ return target
71
+ finally:
72
+ if created and not verified:
73
+ target.unlink()
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.4
2
+ Name: colibri-artifacts
3
+ Version: 0.1.0
4
+ Summary: Command-line client for the Colibri Artifacts repository
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: httpx<1,>=0.27
8
+ Provides-Extra: publish
9
+ Requires-Dist: build<2,>=1.2; extra == "publish"
10
+ Requires-Dist: twine<7,>=6; extra == "publish"
11
+
12
+ # Colibri Artifacts
13
+
14
+ A command-line client and a separate HTTP server for arbitrary files,
15
+ not a package manager. **Only the client is intended for PyPI.** Installing the
16
+ client does not install or run the server.
17
+
18
+ An artifact is identified by **project + version**. Only one file can be uploaded
19
+ for each pair. The original filename is preserved and returned when downloading,
20
+ but is not used to look up the artifact.
21
+ `latest` means the project's most recently uploaded version, not the highest
22
+ SemVer version. Uploading an existing version is rejected; there are no API
23
+ methods to delete or modify artifacts.
24
+
25
+ ## Client installation
26
+
27
+ Requires Python 3.10+. To install the client from the repository root:
28
+
29
+ ```bash
30
+ python3 -m venv .venv
31
+ . .venv/bin/activate
32
+ pip install .
33
+ colibri-artifacts --help
34
+ ```
35
+
36
+ After the client has been published to PyPI, installation will be:
37
+
38
+ ```bash
39
+ pip install colibri-artifacts
40
+ ```
41
+
42
+ The package has **not been published yet**, and availability of the package
43
+ name has not been checked. Until then, install from source or a built wheel.
44
+ You can also run the client with `python -m colibri_artifacts`.
45
+
46
+ ### Configure the server
47
+
48
+ The client connects to `http://127.0.0.1:8000` by default. To use your server:
49
+
50
+ ```bash
51
+ export ARTIFACTS_URL=http://artifacts.internal:8000
52
+ ```
53
+
54
+ Alternatively, pass `--server` **before the subcommand**. It overrides
55
+ `ARTIFACTS_URL` for that invocation:
56
+
57
+ ```bash
58
+ colibri-artifacts --server http://artifacts.internal:8000 download my-service
59
+ ```
60
+
61
+ HTTP and HTTPS URLs are supported, including reverse proxy path prefixes such
62
+ as `https://artifacts.example.com/repository/`. TLS certificates are verified.
63
+ The client uses a 60-second timeout for network inactivity, not for the total
64
+ transfer duration.
65
+
66
+ ### Upload a file
67
+
68
+ ```bash
69
+ colibri-artifacts upload my-service 2026.11.26 ./build.tar.gz
70
+ ```
71
+
72
+ Arguments are `PROJECT VERSION FILE`. The client sends the file as multipart
73
+ form data, using its local basename as the original filename. It prints the
74
+ server's JSON metadata on success. A project does not need to be created first.
75
+ An existing project/version pair cannot be overwritten, even with identical
76
+ contents. `latest` is not a valid upload version.
77
+
78
+ ### Download a file
79
+
80
+ ```bash
81
+ # Download a specific version using the original filename in the current directory.
82
+ colibri-artifacts download my-service 2026.11.26
83
+
84
+ # Download the latest version; omitting VERSION also means latest.
85
+ colibri-artifacts download my-service latest
86
+ colibri-artifacts download my-service
87
+
88
+ # Choose a destination filename.
89
+ colibri-artifacts download my-service latest --output ./release.tar.gz
90
+ ```
91
+
92
+ Arguments are `PROJECT [VERSION]`; `-o` is an alias for `--output`.
93
+ The destination must not already exist, and its parent directory must exist.
94
+ Downloads are streamed to disk and verified against the server's SHA-256
95
+ checksum. A failed transfer or checksum mismatch removes the newly created
96
+ partial file. Existing local files are never overwritten.
97
+ Unsafe or missing server filenames are rejected unless an explicit output
98
+ path is supplied. On success, the client prints the destination path.
99
+
100
+ ### Errors and automation
101
+
102
+ Successful commands exit with code `0`. Network, HTTP, local filesystem,
103
+ response parsing, and checksum errors are written to stderr and exit with code
104
+ `1`. Invalid command-line arguments exit with code `2`.
105
+ Use an explicit version for reproducible CI jobs; `latest` changes when a new
106
+ version is successfully uploaded.
107
+
108
+ ## Server deployment
109
+
110
+ The server is separate from the client. It is installed from `server/` for
111
+ deployment or built into the Docker image; it is **not intended for PyPI**.
112
+ Requires Python 3.10+ and Linux with a local filesystem.
113
+ From the repository root, in a server-side virtual environment:
114
+
115
+ ```bash
116
+ pip install ./server
117
+ colibri-artifacts-server --storage /mnt/artifacts --host 127.0.0.1 --port 8000
118
+ ```
119
+
120
+ You can also run `python -m colibri_artifacts_server`.
121
+ The storage directory is created automatically; the process user must have
122
+ write permission. Instead of `--storage`, you can set the `ARTIFACTS_STORAGE`
123
+ environment variable (default: `./data`).
124
+ By default, the server listens only on `127.0.0.1:8000`.
125
+ Interactive API documentation: <http://127.0.0.1:8000/docs>.
126
+
127
+ **There is no authentication.** Anyone with access to the server can download
128
+ files and claim new versions, including by uploading arbitrary amounts of data.
129
+ Do not expose the port to the Internet; use a trusted network, firewall, or
130
+ reverse proxy with TLS, authentication, and request size limits.
131
+ To allow access from a trusted network, explicitly set `--host 0.0.0.0`.
132
+
133
+ ## HTTP API
134
+
135
+ The client wraps these endpoints; direct HTTP access is also supported.
136
+
137
+ Project and version identifiers must be 1–128 ASCII characters. The first
138
+ character must be a letter or digit; subsequent characters may also include
139
+ `.`, `_`, and `-`. Identifiers are case-sensitive.
140
+ `latest` is reserved and cannot be used for uploads.
141
+
142
+ ```bash
143
+ # Upload: multipart field named "file"; version can be any string in the format above.
144
+ curl --fail-with-body \
145
+ -F 'file=@./build.tar.gz' \
146
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
147
+
148
+ # Download a specific version, keeping the original filename.
149
+ curl --fail -OJ \
150
+ http://127.0.0.1:8000/projects/my-service/versions/2026.11.26
151
+
152
+ # Download the project's most recently uploaded version.
153
+ curl --fail -OJ \
154
+ http://127.0.0.1:8000/projects/my-service/versions/latest
155
+ ```
156
+
157
+ An upload returns `201` with `project`, `version`, `filename`, `size` in bytes,
158
+ and `sha256`. An existing version returns `409`, a missing artifact returns
159
+ `404`, an invalid request returns `422`, and delete or modification requests
160
+ return `405`. Path separators and control characters are not allowed in the
161
+ original filename.
162
+
163
+ Downloads include `Content-Disposition: attachment`, `X-Artifact-Version`,
164
+ `X-Checksum-SHA256`, and an `ETag` containing the SHA-256 checksum.
165
+ Responses for `latest` are not cached; specific immutable versions can be
166
+ cached. If uploads happen concurrently, `latest` is determined by the order in
167
+ which they are committed to the catalog.
168
+
169
+ ## Storage and durability
170
+
171
+ The `--storage` directory contains the SQLite catalog, `catalog.sqlite3`, and
172
+ the `objects` directory holding file contents. Stored objects have random
173
+ internal names; the original filename, including Unicode characters, is kept
174
+ in the catalog. Keep the entire storage directory on persistent storage or a
175
+ bind mount. Restarting the server does not change its contents.
176
+
177
+ An upload is first written to a temporary file and synced to disk. The object is
178
+ published without overwriting an existing file, and the catalog record is
179
+ committed in a transaction. Concurrent uploads of the same version result in
180
+ one success and conflicts for the others. A failed upload does not change
181
+ `latest`. Each operation uses its own SQLite connection; database locks
182
+ serialize upload commits.
183
+
184
+ This is **not WORM storage**: deletion is prevented through the HTTP API only.
185
+ An OS administrator or a process with write access to the disk can delete data.
186
+ Use separate storage protections and backups if stronger protection is needed.
187
+ After a crash, temporary or uncataloged objects may remain; they are not
188
+ accessible through the API. Objects are never deleted automatically.
189
+ For a consistent backup, stop the server and copy the **entire** storage
190
+ directory. Network filesystems (NFS/SMB) are not supported: this implementation
191
+ requires correct SQLite locking, hard links, and `fsync` on a local filesystem.
192
+ Multipart uploads may also use the system temporary directory, so ensure it
193
+ has enough free space or set `TMPDIR` before starting the process.
194
+
195
+ ## Docker Compose
196
+
197
+ The container runs as UID/GID `10001`. Prepare permissions for the bind mount:
198
+
199
+ ```bash
200
+ mkdir -p data
201
+ sudo chown 10001:10001 data
202
+ docker compose up -d --build
203
+ ```
204
+
205
+ Compose mounts `./data` at `/data` and publishes the port on localhost only.
206
+ To use a separate disk, replace `./data` with `/mnt/artifacts` in
207
+ `compose.yaml` and set permissions on that directory. For network access,
208
+ configure a reverse proxy or change the port binding while keeping appropriate
209
+ network restrictions.
210
+
211
+ ## Development and tests
212
+
213
+ Install both local packages to run the client tests, server tests, and their
214
+ integration test. This does not publish either package.
215
+
216
+ ```bash
217
+ pip install -e . -e ./server
218
+ python -m unittest discover -s tests -v
219
+ ```
220
+
221
+ To run only the client tests, the server package is not required:
222
+
223
+ ```bash
224
+ python -m unittest discover -s tests -p test_client.py -v
225
+ ```
226
+
227
+ ## Publishing the client to PyPI
228
+
229
+ Build and upload **only the root project**, not `server/`.
230
+ The root distribution contains the client and depends on HTTPX, not FastAPI,
231
+ Uvicorn, or the server package. The server distribution is marked
232
+ `Private :: Do Not Upload` to prevent accidental uploads to PyPI.
233
+
234
+ The client package is prepared for publishing but **has not been published**.
235
+ The name `colibri-artifacts` is provisional; its availability has not been
236
+ checked. Before publishing publicly, choose a license, add it to the project,
237
+ and make sure you are allowed to publish the repository's contents.
238
+ If the name is taken, change `project.name` in `pyproject.toml`.
239
+
240
+ ```bash
241
+ pip install '.[publish]'
242
+ python -m build --outdir dist/client
243
+ python -m twine check dist/client/*
244
+ python -m twine upload dist/client/*
245
+ ```
246
+
247
+ Use a clean `dist/client` directory for each release, and increment the version
248
+ in the root `pyproject.toml` before publishing a new release. PyPI does not allow
249
+ replacing already published distributions.
250
+ Publishing requires your PyPI account and a token or Trusted Publishing.
251
+ Do not store the token in the repository. After publishing under the chosen name:
252
+
253
+ ```bash
254
+ pip install colibri-artifacts
255
+ ```
@@ -0,0 +1,13 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ src/colibri_artifacts/__init__.py
5
+ src/colibri_artifacts/__main__.py
6
+ src/colibri_artifacts/client.py
7
+ src/colibri_artifacts.egg-info/PKG-INFO
8
+ src/colibri_artifacts.egg-info/SOURCES.txt
9
+ src/colibri_artifacts.egg-info/dependency_links.txt
10
+ src/colibri_artifacts.egg-info/entry_points.txt
11
+ src/colibri_artifacts.egg-info/requires.txt
12
+ src/colibri_artifacts.egg-info/top_level.txt
13
+ tests/test_client.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ colibri-artifacts = colibri_artifacts.__main__:main
@@ -0,0 +1,5 @@
1
+ httpx<1,>=0.27
2
+
3
+ [publish]
4
+ build<2,>=1.2
5
+ twine<7,>=6
@@ -0,0 +1 @@
1
+ colibri_artifacts
@@ -0,0 +1,216 @@
1
+ import hashlib
2
+ import io
3
+ import json
4
+ import os
5
+ import tempfile
6
+ import unittest
7
+ from contextlib import redirect_stderr, redirect_stdout
8
+ from pathlib import Path
9
+ from unittest.mock import patch
10
+ from urllib.parse import quote
11
+
12
+ import httpx
13
+
14
+ from colibri_artifacts.__main__ import main
15
+ from colibri_artifacts.client import ClientError, download
16
+
17
+
18
+ class BrokenStream(httpx.SyncByteStream):
19
+ def __iter__(self):
20
+ yield b"partial" * 200_000
21
+ raise httpx.ReadError("connection lost")
22
+
23
+
24
+ class ClientTests(unittest.TestCase):
25
+ def setUp(self):
26
+ self.directory = tempfile.TemporaryDirectory()
27
+ self.addCleanup(self.directory.cleanup)
28
+ self.root = Path(self.directory.name)
29
+
30
+ def run_cli(self, arguments, handler, environment=None):
31
+ stdout, stderr = io.StringIO(), io.StringIO()
32
+ client = httpx.Client(
33
+ base_url="https://artifacts.example/prefix/", transport=httpx.MockTransport(handler)
34
+ )
35
+ with (
36
+ patch.dict(os.environ, environment or {}, clear=True),
37
+ patch("colibri_artifacts.__main__.httpx.Client", return_value=client) as factory,
38
+ redirect_stdout(stdout),
39
+ redirect_stderr(stderr),
40
+ ):
41
+ try:
42
+ main(arguments)
43
+ status = 0
44
+ except SystemExit as error:
45
+ status = error.code
46
+ return status, stdout.getvalue(), stderr.getvalue(), factory
47
+
48
+ def response(self, content=b"artifact", filename="build.zip", **kwargs):
49
+ return httpx.Response(200, content=content, headers={
50
+ "Content-Disposition": f"attachment; filename*=utf-8''{quote(filename)}",
51
+ "X-Checksum-SHA256": hashlib.sha256(content).hexdigest(),
52
+ }, **kwargs)
53
+
54
+ def test_upload_sends_multipart_and_prints_server_metadata(self):
55
+ source = self.root / "build.zip"
56
+ source.write_bytes(b"binary\x00data")
57
+ metadata = {"project": "demo", "version": "1.2", "filename": "build.zip"}
58
+
59
+ def handler(request):
60
+ self.assertEqual(request.method, "POST")
61
+ self.assertEqual(request.url.path, "/prefix/projects/demo/versions/1.2")
62
+ self.assertIn("multipart/form-data", request.headers["content-type"])
63
+ self.assertIn(b'name="file"; filename="build.zip"', request.content)
64
+ self.assertIn(b"binary\x00data", request.content)
65
+ return httpx.Response(201, json=metadata)
66
+
67
+ status, stdout, stderr, factory = self.run_cli(
68
+ ["--server", "https://artifacts.example/prefix", "upload", "demo", "1.2", str(source)],
69
+ handler,
70
+ )
71
+ self.assertEqual(status, 0, stderr)
72
+ self.assertEqual(json.loads(stdout), metadata)
73
+ factory.assert_called_once_with(base_url="https://artifacts.example/prefix/", timeout=60)
74
+
75
+ def test_download_defaults_to_latest_and_uses_environment_server(self):
76
+ target = self.root / "download.zip"
77
+
78
+ def handler(request):
79
+ self.assertEqual(request.url.path, "/prefix/projects/demo/versions/latest")
80
+ return self.response()
81
+
82
+ status, stdout, stderr, factory = self.run_cli(
83
+ ["download", "demo", "-o", str(target)], handler,
84
+ {"ARTIFACTS_URL": "https://artifacts.example/prefix"},
85
+ )
86
+ self.assertEqual(status, 0, stderr)
87
+ self.assertEqual(target.read_bytes(), b"artifact")
88
+ self.assertEqual(stdout.strip(), str(target))
89
+ factory.assert_called_once_with(base_url="https://artifacts.example/prefix/", timeout=60)
90
+
91
+ def test_download_preserves_original_unicode_and_whitespace_filename(self):
92
+ filename = " \u0441\u0431\u043e\u0440\u043a\u0430.zip "
93
+ previous = Path.cwd()
94
+ try:
95
+ os.chdir(self.root)
96
+ with httpx.Client(
97
+ base_url="https://artifacts.example/",
98
+ transport=httpx.MockTransport(lambda request: self.response(filename=filename)),
99
+ ) as client:
100
+ result = download(client, "demo", "1", None)
101
+ self.assertEqual(result, Path(filename))
102
+ self.assertEqual(result.read_bytes(), b"artifact")
103
+ finally:
104
+ os.chdir(previous)
105
+
106
+ def test_existing_destination_is_not_overwritten(self):
107
+ target = self.root / "existing.zip"
108
+ target.write_bytes(b"keep")
109
+ status, stdout, stderr, _ = self.run_cli(
110
+ ["download", "demo", "1", "-o", str(target)], lambda request: self.response()
111
+ )
112
+ self.assertEqual(status, 1)
113
+ self.assertEqual(stdout, "")
114
+ self.assertIn("File exists", stderr)
115
+ self.assertEqual(target.read_bytes(), b"keep")
116
+
117
+ def test_checksum_mismatch_removes_failed_download(self):
118
+ target = self.root / "corrupt.zip"
119
+
120
+ def handler(request):
121
+ response = self.response()
122
+ response.headers["X-Checksum-SHA256"] = "0" * 64
123
+ return response
124
+
125
+ status, stdout, stderr, _ = self.run_cli(
126
+ ["download", "demo", "-o", str(target)], handler
127
+ )
128
+ self.assertEqual(status, 1)
129
+ self.assertEqual(stdout, "")
130
+ self.assertIn("SHA-256 mismatch", stderr)
131
+ self.assertFalse(target.exists())
132
+
133
+ def test_interrupted_download_removes_partial_file(self):
134
+ target = self.root / "partial.zip"
135
+ status, stdout, stderr, _ = self.run_cli(
136
+ ["download", "demo", "-o", str(target)],
137
+ lambda request: httpx.Response(
138
+ 200, stream=BrokenStream(), headers={"X-Checksum-SHA256": "0" * 64}
139
+ ),
140
+ )
141
+ self.assertEqual(status, 1)
142
+ self.assertEqual(stdout, "")
143
+ self.assertIn("connection lost", stderr)
144
+ self.assertFalse(target.exists())
145
+
146
+ def test_unsafe_server_filename_is_rejected(self):
147
+ for filename in ("../escape", r"..\escape", ".", ""):
148
+ with self.subTest(filename=filename):
149
+ with httpx.Client(
150
+ base_url="https://artifacts.example/",
151
+ transport=httpx.MockTransport(
152
+ lambda request: self.response(filename=filename)
153
+ ),
154
+ ) as client:
155
+ with self.assertRaisesRegex(ClientError, "unsafe filename"):
156
+ download(client, "demo", "1", None)
157
+
158
+ def test_missing_checksum_does_not_create_destination(self):
159
+ target = self.root / "unverified.zip"
160
+ status, _, stderr, _ = self.run_cli(
161
+ ["download", "demo", "-o", str(target)],
162
+ lambda request: httpx.Response(200, content=b"unverified"),
163
+ )
164
+ self.assertEqual(status, 1)
165
+ self.assertIn("missing or invalid SHA-256", stderr)
166
+ self.assertFalse(target.exists())
167
+
168
+ def test_http_errors_report_status_without_creating_file(self):
169
+ for status_code in (404, 409, 422, 500):
170
+ with self.subTest(status=status_code):
171
+ target = self.root / "failed.zip"
172
+ status, stdout, stderr, _ = self.run_cli(
173
+ ["download", "demo", "-o", str(target)],
174
+ lambda request: httpx.Response(status_code, json={"detail": "failure"}),
175
+ )
176
+ self.assertEqual(status, 1)
177
+ self.assertEqual(stdout, "")
178
+ self.assertIn(f"HTTP {status_code}", stderr)
179
+ self.assertIn("failure", stderr)
180
+ self.assertFalse(target.exists())
181
+
182
+ def test_network_errors_and_missing_sources_fail_explicitly(self):
183
+ def offline(request):
184
+ raise httpx.ConnectError("server unavailable", request=request)
185
+
186
+ status, stdout, stderr, _ = self.run_cli(["download", "demo"], offline)
187
+ self.assertEqual(status, 1)
188
+ self.assertEqual(stdout, "")
189
+ self.assertIn("server unavailable", stderr)
190
+ status, _, stderr, factory = self.run_cli(
191
+ ["upload", "demo", "1", str(self.root / "missing.zip")], offline
192
+ )
193
+ self.assertEqual(status, 1)
194
+ self.assertIn("No such file", stderr)
195
+
196
+ def test_invalid_identifiers_reserved_version_and_urls_fail_before_requests(self):
197
+ cases = [
198
+ ["upload", "demo", "latest", "file.zip"],
199
+ ["download", "../escape"],
200
+ ["download", "demo", "invalid version"],
201
+ ["--server", "ftp://artifacts.example", "download", "demo"],
202
+ ["--server", "https://artifacts.example/?query=1", "download", "demo"],
203
+ ]
204
+ for arguments in cases:
205
+ with self.subTest(arguments=arguments):
206
+ status, stdout, stderr, factory = self.run_cli(
207
+ arguments, lambda request: self.fail("Unexpected HTTP request")
208
+ )
209
+ self.assertEqual(status, 2)
210
+ self.assertEqual(stdout, "")
211
+ self.assertIn("error:", stderr)
212
+ factory.assert_not_called()
213
+
214
+
215
+ if __name__ == "__main__":
216
+ unittest.main()