Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions development/playbooks/smoker/smoker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
- ../../../src/vars/foreman.yml
- "{{ obsah_state_path }}/parameters.yaml" # this is a hack to load persisted params without enabling persisting
vars:
smoker_version: headers
smoker_base_url: "https://{{ hostvars['quadlet'].ansible_default_ipv4.address }}"
smoker_variables:
username: "{{ foreman_initial_admin_username }}"
password: "{{ foreman_initial_admin_password }}"
headers:
Host: "{{ hostvars['quadlet'].ansible_fqdn }}"
# We want to rely on the OS to already provide the needed packages
smoker_browser_packages: []
pytest_project_packages: []
Expand Down
3 changes: 3 additions & 0 deletions src/roles/foreman/templates/settings.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
:fqdn: {{ foreman_name }}
:foreman_url: {{ foreman_url }}

:hosts:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs cnames

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which makes me wonder, right now the parameter is --certificate-cname, but in reality this is not about certificates (only) [and we already identified that "cname" is wtong]

so should the parameter be something like --alternative-server-name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the over-all principle here in a parameter that is above but feeds into certificates. Since naming is fun, other ideas:

--server-alias (how Apache defines it)
--server-name-alias
--subject-alternative-name (from certificates but still tied to that concept)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like --server-alias.

- {{ foreman_name }}

:ssl_certificate: /etc/foreman/client_cert.pem
:ssl_ca_file: /etc/foreman/katello-default-ca.crt
:ssl_priv_key: /etc/foreman/client_key.pem
Expand Down
10 changes: 8 additions & 2 deletions tests/foreman_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
]

@pytest.fixture(scope="module")
def foreman_status_curl(server):
return server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' http://{FOREMAN_HOST}:{FOREMAN_PORT}/api/v2/ping")
def foreman_status_curl(server, server_fqdn):
return server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' http://{server_fqdn}:{FOREMAN_PORT}/api/v2/ping")

@pytest.fixture(scope="module")
def foreman_status(foreman_status_curl):
Expand Down Expand Up @@ -92,3 +92,9 @@ def test_foreman_domain_in_mail_settings(foremanapi, server_fqdn, setting):
settings = foremanapi.list('settings', search=f'name={setting}')
domain = str.join('.', server_fqdn.split('.')[1:])
assert domain in settings[0]['value']


def test_foreman_host_injection(server):
cmd = server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' --resolve evil.hackers.test:{FOREMAN_PORT}:127.0.0.1 http://evil.hackers.test:{FOREMAN_PORT}/api/v2/ping")
assert cmd.succeeded
assert cmd.stderr == '403'
Loading