mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: add plain-HTTP listeners for various repository configurations to support non-HTTPS access
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -11,7 +11,8 @@ configurations:
|
||||
apk:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'APK_REPO_PORT' | env }}/
|
||||
{% set scheme = 'APK_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('APK_REPO_PORT' if scheme == 'https' else 'APK_REPO_HTTP_PORT') | env }}/
|
||||
url_to_replace: https://dl-cdn.alpinelinux.org/*
|
||||
key: |
|
||||
{{ 'dockerfiles/repos/040d0af5f97a0a44.rsa.pub' | file | indent(8, first=true) }}
|
||||
|
||||
@@ -11,7 +11,8 @@ configurations:
|
||||
- name: demo
|
||||
types: [deb]
|
||||
uris:
|
||||
- https://host.docker.internal:{{ 'APT_REPO_PORT' | env }}/
|
||||
{% set scheme = 'APT_REPO_SCHEME' | env %}
|
||||
- {{ scheme }}://host.docker.internal:{{ ('APT_REPO_PORT' if scheme == 'https' else 'APT_REPO_HTTP_PORT') | env }}/
|
||||
suites: ["./"]
|
||||
uri-to-replace: http://deb.debian.org/*
|
||||
signed-by: |
|
||||
|
||||
@@ -26,7 +26,8 @@ configurations:
|
||||
go:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'GO_REPO_PORT' | env }}/
|
||||
{% set scheme = 'GO_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('GO_REPO_PORT' if scheme == 'https' else 'GO_REPO_HTTP_PORT') | env }}/
|
||||
ruby:
|
||||
repositories: []
|
||||
nuget:
|
||||
|
||||
@@ -23,7 +23,8 @@ configurations:
|
||||
# during the Dockerfile's warm-up step. All other tools just see it as
|
||||
# an ordinary repository, and find the test artifact here.
|
||||
- name: central
|
||||
url: https://host.docker.internal:{{ 'JAVA_REPO_PORT' | env }}/
|
||||
{% set scheme = 'JAVA_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('JAVA_REPO_PORT' if scheme == 'https' else 'JAVA_REPO_HTTP_PORT') | env }}/
|
||||
# Second entry: only SBT needs this. With
|
||||
# -Dsbt.override.build.repos=true (the only way SBT actually consults
|
||||
# this file for project dependencies, not just its own bootstrap), the
|
||||
|
||||
@@ -22,7 +22,8 @@ configurations:
|
||||
npm:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'NPM_REPO_PORT' | env }}/
|
||||
{% set scheme = 'NPM_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('NPM_REPO_PORT' if scheme == 'https' else 'NPM_REPO_HTTP_PORT') | env }}/
|
||||
rust:
|
||||
repositories: []
|
||||
go:
|
||||
|
||||
@@ -30,4 +30,5 @@ configurations:
|
||||
nuget:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'NUGET_REPO_PORT' | env }}/index.json
|
||||
{% set scheme = 'NUGET_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('NUGET_REPO_PORT' if scheme == 'https' else 'NUGET_REPO_HTTP_PORT') | env }}/index.json
|
||||
|
||||
@@ -20,7 +20,8 @@ configurations:
|
||||
php:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'PHP_REPO_PORT' | env }}/
|
||||
{% set scheme = 'PHP_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('PHP_REPO_PORT' if scheme == 'https' else 'PHP_REPO_HTTP_PORT') | env }}/
|
||||
npm:
|
||||
repositories: []
|
||||
rust:
|
||||
|
||||
@@ -16,7 +16,8 @@ configurations:
|
||||
python:
|
||||
repositories:
|
||||
- name: demo
|
||||
index-url: https://host.docker.internal:{{ 'PYPI_REPO_PORT' | env }}/simple/
|
||||
{% set scheme = 'PYPI_REPO_SCHEME' | env %}
|
||||
index-url: {{ scheme }}://host.docker.internal:{{ ('PYPI_REPO_PORT' if scheme == 'https' else 'PYPI_REPO_HTTP_PORT') | env }}/simple/
|
||||
java:
|
||||
repositories: []
|
||||
php:
|
||||
|
||||
@@ -28,6 +28,7 @@ configurations:
|
||||
ruby:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'RUBY_REPO_PORT' | env }}/
|
||||
{% set scheme = 'RUBY_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('RUBY_REPO_PORT' if scheme == 'https' else 'RUBY_REPO_HTTP_PORT') | env }}/
|
||||
nuget:
|
||||
repositories: []
|
||||
|
||||
@@ -24,7 +24,8 @@ configurations:
|
||||
rust:
|
||||
repositories:
|
||||
- name: demo
|
||||
url: https://host.docker.internal:{{ 'CARGO_REPO_PORT' | env }}/
|
||||
{% set scheme = 'CARGO_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('CARGO_REPO_PORT' if scheme == 'https' else 'CARGO_REPO_HTTP_PORT') | env }}/
|
||||
is_sparse: true
|
||||
go:
|
||||
repositories: []
|
||||
|
||||
@@ -13,7 +13,8 @@ configurations:
|
||||
yum:
|
||||
repositories:
|
||||
- name: demo
|
||||
index-url: https://host.docker.internal:{{ 'YUM_REPO_PORT' | env }}/
|
||||
{% set scheme = 'YUM_REPO_SCHEME' | env %}
|
||||
index-url: {{ scheme }}://host.docker.internal:{{ ('YUM_REPO_PORT' if scheme == 'https' else 'YUM_REPO_HTTP_PORT') | env }}/
|
||||
index-url-to-replace: https://mirrors.rockylinux.org/*
|
||||
keys: []
|
||||
python:
|
||||
|
||||
@@ -5,6 +5,7 @@ COPY --from=generated-config Python.yaml /config.yaml
|
||||
RUN id-configurator apply --config /config.yaml --src /src --dst /dst
|
||||
FROM target AS runtime
|
||||
ARG PYPI_REPO_PORT
|
||||
ARG PYPI_REPO_SCHEME
|
||||
# Warm up uv and poetry themselves from the real, network-reachable PyPI
|
||||
# while the default index is still in place, so the actual tests below
|
||||
# never need anything but the fixture repository configured by
|
||||
@@ -20,5 +21,5 @@ RUN uv pip install --system idconfiguratortestpkg \
|
||||
&& python3 -c "import idconfiguratortestpkg"
|
||||
RUN mkdir -p /tmp/poetrytest && cd /tmp/poetrytest \
|
||||
&& poetry init -n --name poetrytest \
|
||||
&& poetry source add --priority explicit demo "https://host.docker.internal:${PYPI_REPO_PORT}/simple/" \
|
||||
&& poetry source add --priority explicit demo "${PYPI_REPO_SCHEME}://host.docker.internal:${PYPI_REPO_PORT}/simple/" \
|
||||
&& poetry add idconfiguratortestpkg --source demo
|
||||
|
||||
@@ -5,6 +5,7 @@ COPY --from=generated-config Python.yaml /config.yaml
|
||||
RUN id-configurator apply --config /config.yaml --src /src --dst /dst
|
||||
FROM target AS runtime
|
||||
ARG PYPI_REPO_PORT
|
||||
ARG PYPI_REPO_SCHEME
|
||||
# Warm up uv and poetry themselves from the real, network-reachable PyPI
|
||||
# while the default index is still in place, so the actual tests below
|
||||
# never need anything but the fixture repository configured by
|
||||
@@ -20,5 +21,5 @@ RUN uv pip install --system idconfiguratortestpkg \
|
||||
&& python3 -c "import idconfiguratortestpkg"
|
||||
RUN mkdir -p /tmp/poetrytest && cd /tmp/poetrytest \
|
||||
&& poetry init -n --name poetrytest \
|
||||
&& poetry source add --priority explicit demo "https://host.docker.internal:${PYPI_REPO_PORT}/simple/" \
|
||||
&& poetry source add --priority explicit demo "${PYPI_REPO_SCHEME}://host.docker.internal:${PYPI_REPO_PORT}/simple/" \
|
||||
&& poetry add idconfiguratortestpkg --source demo
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,28 @@ server {
|
||||
# templates, since the host:port this fixture is actually reached on is
|
||||
# only known once tox-docker starts the container, not at image-build
|
||||
# time. $http_host reflects exactly what the client (cargo) used to
|
||||
# connect, e.g. host.docker.internal:55123.
|
||||
# connect, e.g. host.docker.internal:55123; $scheme likewise reflects
|
||||
# whichever of this file's two listeners actually served the request.
|
||||
location = /config.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' 'https://$http_host';
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-rust-http tox env that verifies
|
||||
# id-configurator correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
|
||||
location = /config.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,29 @@ server {
|
||||
# its tarball URL, since the host:port this fixture is actually reached
|
||||
# on is only known once tox-docker starts the container, not at
|
||||
# image-build time. $http_host reflects exactly what the client (npm)
|
||||
# used to connect, e.g. host.docker.internal:55123.
|
||||
# used to connect, e.g. host.docker.internal:55123; $scheme likewise
|
||||
# reflects whichever of this file's two listeners actually served the
|
||||
# request.
|
||||
location = /idconfiguratortestpkg {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' 'https://$http_host';
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-npm-http tox env that verifies
|
||||
# id-configurator correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
|
||||
location = /idconfiguratortestpkg {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,28 @@ server {
|
||||
# fields, since the host:port this fixture is actually reached on is
|
||||
# only known once tox-docker starts the container, not at image-build
|
||||
# time. $http_host reflects exactly what the client (nuget) used to
|
||||
# connect, e.g. host.docker.internal:55123.
|
||||
# connect, e.g. host.docker.internal:55123; $scheme likewise reflects
|
||||
# whichever of this file's two listeners actually served the request.
|
||||
location = /index.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' 'https://$http_host';
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-nuget-http tox env that verifies
|
||||
# id-configurator correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
|
||||
location = /index.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,28 @@ server {
|
||||
# since the host:port this fixture is actually reached on is only known
|
||||
# once tox-docker starts the container, not at image-build time.
|
||||
# $http_host reflects exactly what the client (Composer) used to
|
||||
# connect, e.g. host.docker.internal:55123.
|
||||
# connect, e.g. host.docker.internal:55123; $scheme likewise reflects
|
||||
# whichever of this file's two listeners actually served the request.
|
||||
location = /packages.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' 'https://$http_host';
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-php-http tox env that verifies
|
||||
# id-configurator correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
|
||||
location = /packages.json {
|
||||
default_type application/json;
|
||||
sub_filter '__BASE_URL__' '$scheme://$http_host';
|
||||
sub_filter_once off;
|
||||
sub_filter_types application/json;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -8,3 +8,13 @@ server {
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
# Plain-HTTP listener, for the module-*-http tox envs that verify id-configurator
|
||||
# correctly configures a non-HTTPS repository.
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
root /srv;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
@@ -353,6 +353,30 @@ def test_apply_writes_lein_profiles(tmp_path) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_apply_marks_non_https_lein_repository_as_insecure(tmp_path) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
"organisation": "InterDiode",
|
||||
"configurations": {
|
||||
"java": {
|
||||
"repositories": [
|
||||
{"name": "interdiode", "url": "http://example.invalid/maven"}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
dst = tmp_path / "dst"
|
||||
context = Context(config=make_config(data), dst=dst, src=None)
|
||||
|
||||
JavaModule().apply(context)
|
||||
|
||||
profiles = (dst / "root/.lein/profiles.clj").read_text(encoding="utf-8")
|
||||
assert profiles == (
|
||||
"{:user {:repositories "
|
||||
'[["interdiode" {:url "http://example.invalid/maven" :insecure true}]]}}\n'
|
||||
)
|
||||
|
||||
|
||||
def test_apply_with_certificates_and_repositories_writes_both(tmp_path) -> None:
|
||||
src = tmp_path / "src"
|
||||
(src / "usr/lib/jvm/java-21/lib/security").mkdir(parents=True)
|
||||
|
||||
Reference in New Issue
Block a user