mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-09-02 05:53:14 +00:00
Test matrix-bridge-mautrix-bluesky with Molecule
This commit is contained in:
@@ -131,6 +131,7 @@
|
||||
"roles/custom/matrix-bot-meowlnir/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-heisenbridge/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-hookshot/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-bluesky/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-discord/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-gmessages/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-meta-instagram/defaults/main.yml",
|
||||
@@ -161,6 +162,7 @@
|
||||
"roles/custom/matrix-authentication-service/defaults/main.yml",
|
||||
"roles/custom/matrix-bot-honoroit/defaults/main.yml",
|
||||
"roles/custom/matrix-bot-meowlnir/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-bluesky/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-gmessages/defaults/main.yml",
|
||||
"roles/custom/matrix-bridge-mautrix-slack/defaults/main.yml",
|
||||
"roles/custom/matrix-client-fluffychat/defaults/main.yml",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
- name: Include roles for mautrix-bluesky Molecule tests
|
||||
hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Include roles for mautrix-bluesky Molecule tests
|
||||
ansible.builtin.include_role:
|
||||
name: "{{ role_name }}"
|
||||
public: true
|
||||
loop:
|
||||
- com.devture.ansible.role.playbook_help
|
||||
- com.devture.ansible.role.systemd_docker_base
|
||||
- "custom/{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
|
||||
loop_control:
|
||||
loop_var: role_name
|
||||
|
||||
- name: Ensure mautrix-bluesky is started
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Ensure systemd daemon is reloaded
|
||||
ansible.builtin.systemd_service:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure the mautrix-bluesky systemd service is started
|
||||
ansible.builtin.systemd_service:
|
||||
name: matrix-mautrix-bluesky.service
|
||||
state: started
|
||||
@@ -0,0 +1,94 @@
|
||||
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
requirements-file: requirements.yml
|
||||
force: true
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: mautrix-bluesky-${MOLECULE_DISTRO:-ubuntu2604}-default
|
||||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2604}-ansible:latest"
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
pre_build_image: true
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
callback_result_format: yaml
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
matrix_bridge_mautrix_bluesky_container_network: mautrix-bluesky-molecule
|
||||
|
||||
# The stub is not a real homeserver, and the scenario carries no Bluesky account or
|
||||
# credentials. An idle, logged-out bridge is the intended third-party boundary.
|
||||
matrix_bridge_mautrix_bluesky_homeserver_address: http://matrix.molecule.local:8008
|
||||
matrix_bridge_mautrix_bluesky_homeserver_domain: molecule.local
|
||||
|
||||
# Postgres is this role's only database engine. The non-default identity makes schema
|
||||
# creation evidence that the role composed and delivered the scenario connection URI.
|
||||
matrix_bridge_mautrix_bluesky_database_hostname: matrix-postgres-molecule
|
||||
matrix_bridge_mautrix_bluesky_database_name: molecule_bluesky
|
||||
matrix_bridge_mautrix_bluesky_database_username: molecule_bluesky
|
||||
matrix_bridge_mautrix_bluesky_database_password: molecule_pg_password_74b0e2
|
||||
|
||||
# Test-only fixtures which must reach config.yaml and registration.yaml.
|
||||
matrix_bridge_mautrix_bluesky_appservice_token: molecule_bluesky_as_token_1f27ac
|
||||
matrix_bridge_mautrix_bluesky_homeserver_token: molecule_bluesky_hs_token_91c0d8
|
||||
|
||||
# Each value differs from the role default, allowing parsed checks to prove rendering.
|
||||
matrix_bridge_mautrix_bluesky_appservice_bot_username: molecule-blueskybot
|
||||
matrix_bridge_mautrix_bluesky_appservice_bot_displayname: Molecule Bluesky Bot
|
||||
matrix_bridge_mautrix_bluesky_appservice_bot_avatar: mxc://molecule.local/blueskyAvatarFixture
|
||||
matrix_bridge_mautrix_bluesky_bridge_command_prefix: "!molecule-bluesky"
|
||||
matrix_bridge_mautrix_bluesky_bridge_permissions:
|
||||
"*": relay
|
||||
molecule.local: admin
|
||||
matrix_bridge_mautrix_bluesky_matrix_federate_rooms: false
|
||||
matrix_bridge_mautrix_bluesky_backfill_enabled: false
|
||||
matrix_bridge_mautrix_bluesky_backfill_max_initial_messages: 23
|
||||
matrix_bridge_mautrix_bluesky_backfill_max_catchup_messages: 37
|
||||
matrix_bridge_mautrix_bluesky_provisioning_shared_secret: molecule_provisioning_secret_2f018a
|
||||
matrix_bridge_mautrix_bluesky_logging_level: info
|
||||
|
||||
# Traefik is not started. These settings exercise the public address consumed by the
|
||||
# bridge and the route labels consumed by Docker.
|
||||
matrix_bridge_mautrix_bluesky_exposure_enabled: true
|
||||
matrix_bridge_mautrix_bluesky_exposure_hostname: bluesky-api.molecule.local
|
||||
matrix_bridge_mautrix_bluesky_exposure_path_prefix: /bridges/bluesky-api
|
||||
matrix_bridge_mautrix_bluesky_scheme: http
|
||||
matrix_bridge_mautrix_bluesky_container_labels_traefik_entrypoints: web
|
||||
matrix_bridge_mautrix_bluesky_container_labels_additional_labels: |
|
||||
molecule.bluesky.coverage=enabled
|
||||
|
||||
# verify.yml is a separate play, where role defaults are out of scope.
|
||||
matrix_bridge_mautrix_bluesky_base_path: /matrix/mautrix-bluesky
|
||||
matrix_bridge_mautrix_bluesky_config_path: /matrix/mautrix-bluesky/config
|
||||
matrix_bridge_mautrix_bluesky_data_path: /matrix/mautrix-bluesky/data
|
||||
env:
|
||||
# Workaround for https://github.com/ansible/molecule/issues/4391
|
||||
ANSIBLE_ROLES_PATH: ${MOLECULE_PROJECT_DIRECTORY}/../..:/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:${ANSIBLE_HOME:-~/.ansible}/roles
|
||||
scenario:
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- destroy
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- idempotence
|
||||
- verify
|
||||
- cleanup
|
||||
- destroy
|
||||
verifier:
|
||||
name: ansible
|
||||
@@ -0,0 +1,87 @@
|
||||
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
- name: Prepare mautrix-bluesky Molecule tests
|
||||
hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
|
||||
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Ensure apt cache is updated
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 600
|
||||
when: ansible_facts['os_family'] == 'Debian'
|
||||
|
||||
- name: Ensure required packages are installed
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- python3-requests
|
||||
- fuse-overlayfs
|
||||
state: present
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
ansible.builtin.include_role:
|
||||
name: ansible-role-docker
|
||||
vars:
|
||||
docker_daemon_options:
|
||||
storage-driver: fuse-overlayfs
|
||||
|
||||
- name: Ensure the matrix group exists
|
||||
ansible.builtin.group:
|
||||
name: "{{ matrix_group_name }}"
|
||||
gid: "{{ matrix_user_gid }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure the matrix user exists
|
||||
ansible.builtin.user:
|
||||
name: "{{ matrix_user_name }}"
|
||||
uid: "{{ matrix_user_uid }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
create_home: false
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: Ensure the base data path exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_base_data_path }}"
|
||||
state: directory
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
mode: "0750"
|
||||
|
||||
# The role creates this during converge, but the two dependencies need it first.
|
||||
- name: Ensure the container network the role attaches to exists
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- network
|
||||
- create
|
||||
- "{{ matrix_bridge_mautrix_bluesky_container_network }}"
|
||||
register: mautrix_bluesky_molecule_network
|
||||
changed_when: mautrix_bluesky_molecule_network.rc == 0
|
||||
failed_when:
|
||||
- mautrix_bluesky_molecule_network.rc != 0
|
||||
- "'already exists' not in mautrix_bluesky_molecule_network.stderr"
|
||||
|
||||
- name: Ensure Postgres is running
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/postgres.yml"
|
||||
vars:
|
||||
molecule_shared_postgres_network: "{{ matrix_bridge_mautrix_bluesky_container_network }}"
|
||||
molecule_shared_postgres_database: "{{ matrix_bridge_mautrix_bluesky_database_name }}"
|
||||
molecule_shared_postgres_username: "{{ matrix_bridge_mautrix_bluesky_database_username }}"
|
||||
molecule_shared_postgres_password: "{{ matrix_bridge_mautrix_bluesky_database_password }}"
|
||||
|
||||
# The logged-out bridge still authenticates its appservice bot during startup.
|
||||
- name: Ensure the homeserver stub is running
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/homeserver-stub.yml"
|
||||
vars:
|
||||
molecule_shared_stub_network: "{{ matrix_bridge_mautrix_bluesky_container_network }}"
|
||||
molecule_shared_stub_server_name: "{{ matrix_bridge_mautrix_bluesky_homeserver_domain }}"
|
||||
molecule_shared_stub_user_id: "@{{ matrix_bridge_mautrix_bluesky_appservice_bot_username }}:{{ matrix_bridge_mautrix_bluesky_homeserver_domain }}"
|
||||
@@ -0,0 +1 @@
|
||||
../../../../../molecule-shared/requirements.yml
|
||||
@@ -0,0 +1,386 @@
|
||||
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
# Proves the logged-out bridge starts, accepts the role-rendered configuration and
|
||||
# registration, migrates real Postgres, and opens its appservice listener. A Bluesky
|
||||
# login is deliberately outside this scenario's third-party boundary.
|
||||
- name: Verify mautrix-bluesky
|
||||
hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
|
||||
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
|
||||
vars:
|
||||
mautrix_bluesky_config: "{{ mautrix_bluesky_config_file.content | b64decode | from_yaml }}"
|
||||
mautrix_bluesky_registration: "{{ mautrix_bluesky_registration_file.content | b64decode | from_yaml }}"
|
||||
mautrix_bluesky_labels_rendered: "{{ mautrix_bluesky_labels_file.content | b64decode }}"
|
||||
mautrix_bluesky_expected_public_address: http://bluesky-api.molecule.local/bridges/bluesky-api
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
# A Renovate bump changes this source of truth and therefore the image expectation.
|
||||
- name: Load the role's defaults under a separate name
|
||||
ansible.builtin.include_vars:
|
||||
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/main.yml"
|
||||
name: mautrix_bluesky_role_defaults
|
||||
|
||||
- name: Wait for the mautrix-bluesky service to become active
|
||||
ansible.builtin.systemd_service:
|
||||
name: matrix-mautrix-bluesky.service
|
||||
register: mautrix_bluesky_service
|
||||
until: mautrix_bluesky_service.status.ActiveState == 'active'
|
||||
retries: 30
|
||||
delay: 5
|
||||
failed_when: false
|
||||
|
||||
# Restart=always makes ActiveState insufficient for detecting a crash loop.
|
||||
- name: Assert the service is active and has not been restarting
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_service.status.ActiveState == 'active'
|
||||
- mautrix_bluesky_service.status.NRestarts is defined
|
||||
- mautrix_bluesky_service.status.NRestarts | int == 0
|
||||
fail_msg: >-
|
||||
matrix-mautrix-bluesky.service is
|
||||
{{ mautrix_bluesky_service.status.ActiveState | default('unknown') }} after
|
||||
{{ mautrix_bluesky_service.status.NRestarts | default('?') }} restart(s)
|
||||
success_msg: "matrix-mautrix-bluesky.service is active and has not restarted"
|
||||
|
||||
- name: Wait for the bridge liveness endpoint
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- run
|
||||
- --rm
|
||||
- --network={{ matrix_bridge_mautrix_bluesky_container_network }}
|
||||
- "{{ molecule_shared_image_curl }}"
|
||||
- --silent
|
||||
- --output
|
||||
- /dev/null
|
||||
- --write-out
|
||||
- "HTTP_STATUS=%{http_code}"
|
||||
- http://matrix-mautrix-bluesky:29340/_matrix/mau/live
|
||||
register: mautrix_bluesky_live
|
||||
changed_when: false
|
||||
until: mautrix_bluesky_live.rc == 0 and mautrix_bluesky_live.stdout == 'HTTP_STATUS=200'
|
||||
retries: 24
|
||||
delay: 5
|
||||
failed_when: false
|
||||
|
||||
- name: Wait for the bridge readiness endpoint
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- run
|
||||
- --rm
|
||||
- --network={{ matrix_bridge_mautrix_bluesky_container_network }}
|
||||
- "{{ molecule_shared_image_curl }}"
|
||||
- --silent
|
||||
- --output
|
||||
- /dev/null
|
||||
- --write-out
|
||||
- "HTTP_STATUS=%{http_code}"
|
||||
- http://matrix-mautrix-bluesky:29340/_matrix/mau/ready
|
||||
register: mautrix_bluesky_ready
|
||||
changed_when: false
|
||||
until: mautrix_bluesky_ready.rc == 0 and mautrix_bluesky_ready.stdout == 'HTTP_STATUS=200'
|
||||
retries: 24
|
||||
delay: 5
|
||||
failed_when: false
|
||||
|
||||
- name: Assert the bridge is live and ready on the configured appservice port
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_live.rc == 0
|
||||
- mautrix_bluesky_live.stdout == 'HTTP_STATUS=200'
|
||||
- mautrix_bluesky_ready.rc == 0
|
||||
- mautrix_bluesky_ready.stdout == 'HTTP_STATUS=200'
|
||||
fail_msg: >-
|
||||
Health probes returned live={{ mautrix_bluesky_live.stdout | default('none') }}
|
||||
(rc={{ mautrix_bluesky_live.rc | default('?') }}) and
|
||||
ready={{ mautrix_bluesky_ready.stdout | default('none') }}
|
||||
(rc={{ mautrix_bluesky_ready.rc | default('?') }})
|
||||
success_msg: "The bridge is live and ready on the configured appservice port"
|
||||
|
||||
# This authenticated endpoint exercises the provisioning middleware and the network
|
||||
# connector's login-flow API without starting a Bluesky login or carrying credentials.
|
||||
- name: Query the authenticated provisioning login flows
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- run
|
||||
- --rm
|
||||
- --network={{ matrix_bridge_mautrix_bluesky_container_network }}
|
||||
- "{{ molecule_shared_image_curl }}"
|
||||
- --silent
|
||||
- --show-error
|
||||
- --fail-with-body
|
||||
- --header
|
||||
- "Authorization: Bearer {{ matrix_bridge_mautrix_bluesky_provisioning_shared_secret }}"
|
||||
- "http://matrix-mautrix-bluesky:29340/_matrix/provision/v3/login/flows?user_id=%40alice%3Amolecule.local"
|
||||
register: mautrix_bluesky_login_flows
|
||||
changed_when: false
|
||||
|
||||
- name: Query the provisioning API with an invalid secret
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- run
|
||||
- --rm
|
||||
- --network={{ matrix_bridge_mautrix_bluesky_container_network }}
|
||||
- "{{ molecule_shared_image_curl }}"
|
||||
- --silent
|
||||
- --output
|
||||
- /dev/null
|
||||
- --write-out
|
||||
- "HTTP_STATUS=%{http_code}"
|
||||
- --header
|
||||
- "Authorization: Bearer definitely-wrong-molecule-secret"
|
||||
- "http://matrix-mautrix-bluesky:29340/_matrix/provision/v3/login/flows?user_id=%40alice%3Amolecule.local"
|
||||
register: mautrix_bluesky_login_flows_unauthorized
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Assert the live provisioning API enforces auth and advertises login flows
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_login_flows.rc == 0
|
||||
- (mautrix_bluesky_login_flows.stdout | from_json).flows is sequence
|
||||
- (mautrix_bluesky_login_flows.stdout | from_json).flows | length > 0
|
||||
- (mautrix_bluesky_login_flows.stdout | from_json).flows | map(attribute='id') | list == ['password']
|
||||
- mautrix_bluesky_login_flows_unauthorized.rc == 0
|
||||
- mautrix_bluesky_login_flows_unauthorized.stdout == 'HTTP_STATUS=401'
|
||||
fail_msg: "The provisioning API did not enforce its secret or return Bluesky login flows"
|
||||
success_msg: "The provisioning API enforces its secret and returns Bluesky login flows"
|
||||
|
||||
- name: Read the configuration the role rendered
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ matrix_bridge_mautrix_bluesky_config_path }}/config.yaml"
|
||||
register: mautrix_bluesky_config_file
|
||||
|
||||
- name: Assert the rendered configuration carries the appservice identity
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_config.homeserver.address == matrix_bridge_mautrix_bluesky_homeserver_address
|
||||
- mautrix_bluesky_config.homeserver.domain == matrix_bridge_mautrix_bluesky_homeserver_domain
|
||||
- mautrix_bluesky_config.appservice.id == 'bluesky'
|
||||
- mautrix_bluesky_config.appservice.address == 'http://matrix-mautrix-bluesky:29340'
|
||||
- mautrix_bluesky_config.appservice.public_address == mautrix_bluesky_expected_public_address
|
||||
- mautrix_bluesky_config.appservice.bot.username == matrix_bridge_mautrix_bluesky_appservice_bot_username
|
||||
- mautrix_bluesky_config.appservice.bot.displayname == matrix_bridge_mautrix_bluesky_appservice_bot_displayname
|
||||
- mautrix_bluesky_config.appservice.bot.avatar == matrix_bridge_mautrix_bluesky_appservice_bot_avatar
|
||||
- mautrix_bluesky_config.appservice.as_token == matrix_bridge_mautrix_bluesky_appservice_token
|
||||
- mautrix_bluesky_config.appservice.hs_token == matrix_bridge_mautrix_bluesky_homeserver_token
|
||||
fail_msg: "The rendered configuration does not carry the scenario's appservice identity"
|
||||
success_msg: "The rendered configuration carries the scenario's appservice identity"
|
||||
|
||||
- name: Assert the rendered configuration carries non-default bridge behavior
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_config.bridge.command_prefix == matrix_bridge_mautrix_bluesky_bridge_command_prefix
|
||||
- mautrix_bluesky_config.bridge.permissions['*'] == 'relay'
|
||||
- mautrix_bluesky_config.bridge.permissions[matrix_bridge_mautrix_bluesky_homeserver_domain] == 'admin'
|
||||
- not mautrix_bluesky_config.matrix.federate_rooms
|
||||
- mautrix_bluesky_config.provisioning.shared_secret == matrix_bridge_mautrix_bluesky_provisioning_shared_secret
|
||||
- mautrix_bluesky_config.logging.min_level == matrix_bridge_mautrix_bluesky_logging_level
|
||||
fail_msg: "The rendered configuration does not carry the scenario's bridge behavior"
|
||||
success_msg: "The rendered configuration carries the scenario's bridge behavior"
|
||||
|
||||
- name: Assert the rendered configuration carries the non-default backfill policy
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not mautrix_bluesky_config.backfill.enabled
|
||||
- mautrix_bluesky_config.backfill.max_initial_messages == 23
|
||||
- mautrix_bluesky_config.backfill.max_catchup_messages == 37
|
||||
fail_msg: "The rendered configuration does not carry the scenario's backfill policy"
|
||||
success_msg: "The rendered configuration carries the scenario's backfill policy"
|
||||
|
||||
- name: Assert the configuration points at the scenario's Postgres database
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_config.database.type == 'postgres'
|
||||
- matrix_bridge_mautrix_bluesky_database_username in mautrix_bluesky_config.database.uri
|
||||
- matrix_bridge_mautrix_bluesky_database_hostname in mautrix_bluesky_config.database.uri
|
||||
- matrix_bridge_mautrix_bluesky_database_name in mautrix_bluesky_config.database.uri
|
||||
fail_msg: >-
|
||||
database.uri is {{ mautrix_bluesky_config.database.uri | default('unset') }}, which
|
||||
was not composed from the scenario's connection settings
|
||||
success_msg: "The configuration points at the scenario's Postgres database"
|
||||
|
||||
- name: Read the appservice registration the role rendered
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ matrix_bridge_mautrix_bluesky_config_path }}/registration.yaml"
|
||||
register: mautrix_bluesky_registration_file
|
||||
|
||||
- name: Assert the registration carries the configured handshake values
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_registration.id == 'bluesky'
|
||||
- mautrix_bluesky_registration.as_token == matrix_bridge_mautrix_bluesky_appservice_token
|
||||
- mautrix_bluesky_registration.hs_token == matrix_bridge_mautrix_bluesky_homeserver_token
|
||||
- mautrix_bluesky_registration.sender_localpart == '_bot_' + matrix_bridge_mautrix_bluesky_appservice_bot_username
|
||||
- mautrix_bluesky_registration.url == 'http://matrix-mautrix-bluesky:29340'
|
||||
fail_msg: "The registration does not carry the configured handshake values"
|
||||
success_msg: "The registration carries the configured handshake values"
|
||||
|
||||
- name: Assert the registration namespaces cover only Bluesky ghosts and the bridge bot
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_ghost_regex | length > 0
|
||||
- mautrix_bluesky_bot_regex | length > 0
|
||||
- mautrix_bluesky_ghost_mxid is match(mautrix_bluesky_ghost_regex)
|
||||
- mautrix_bluesky_wrong_ghost_mxid is not match(mautrix_bluesky_ghost_regex)
|
||||
- mautrix_bluesky_bot_mxid is match(mautrix_bluesky_bot_regex)
|
||||
fail_msg: "The registration namespaces do not cover only Bluesky ghosts and the bot"
|
||||
success_msg: "The registration namespaces cover only Bluesky ghosts and the bot"
|
||||
vars:
|
||||
mautrix_bluesky_user_regexes: "{{ mautrix_bluesky_registration.namespaces.users | map(attribute='regex') | list }}"
|
||||
mautrix_bluesky_ghost_regex: "{{ mautrix_bluesky_user_regexes | select('search', 'bluesky_') | first | default('') }}"
|
||||
mautrix_bluesky_bot_regex: "{{ mautrix_bluesky_user_regexes | reject('search', 'bluesky_') | first | default('') }}"
|
||||
mautrix_bluesky_ghost_mxid: "@bluesky_did_plc_moleculefixture:{{ matrix_bridge_mautrix_bluesky_homeserver_domain }}"
|
||||
mautrix_bluesky_wrong_ghost_mxid: "@twitter_did_plc_moleculefixture:{{ matrix_bridge_mautrix_bluesky_homeserver_domain }}"
|
||||
mautrix_bluesky_bot_mxid: "@{{ matrix_bridge_mautrix_bluesky_appservice_bot_username }}:{{ matrix_bridge_mautrix_bluesky_homeserver_domain }}"
|
||||
|
||||
# Tables can appear only after hostname resolution, authentication, and real migrations.
|
||||
- name: List the tables the bridge created in Postgres
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- exec
|
||||
- matrix-postgres-molecule
|
||||
- psql
|
||||
- --username={{ matrix_bridge_mautrix_bluesky_database_username }}
|
||||
- --dbname={{ matrix_bridge_mautrix_bluesky_database_name }}
|
||||
- --tuples-only
|
||||
- --no-align
|
||||
- "--command=SELECT tablename FROM pg_tables WHERE schemaname = 'public'"
|
||||
register: mautrix_bluesky_tables
|
||||
changed_when: false
|
||||
|
||||
- name: Assert the bridge migrated its schema into the configured database
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_tables.rc == 0
|
||||
- "'version' in mautrix_bluesky_table_names"
|
||||
- "'portal' in mautrix_bluesky_table_names"
|
||||
- "'user_login' in mautrix_bluesky_table_names"
|
||||
- "'message' in mautrix_bluesky_table_names"
|
||||
- mautrix_bluesky_table_names | length > 10
|
||||
fail_msg: >-
|
||||
The bridge did not migrate its schema into {{ matrix_bridge_mautrix_bluesky_database_name }}
|
||||
(found {{ mautrix_bluesky_table_names | length }} table(s))
|
||||
success_msg: "The bridge migrated its schema into the configured database"
|
||||
vars:
|
||||
mautrix_bluesky_table_names: "{{ mautrix_bluesky_tables.stdout_lines | select | list }}"
|
||||
|
||||
- name: Read the labels the role rendered
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ matrix_bridge_mautrix_bluesky_base_path }}/labels"
|
||||
register: mautrix_bluesky_labels_file
|
||||
|
||||
- name: Assert the labels route the public endpoint to the appservice port
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'traefik.enable=true' in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.docker.network=' + matrix_bridge_mautrix_bluesky_container_network in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.http.services.matrix-mautrix-bluesky-exposure.loadbalancer.server.port=29340' in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.http.routers.matrix-mautrix-bluesky-exposure.rule=Host(`bluesky-api.molecule.local`) && PathPrefix(`/bridges/bluesky-api`)' in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.http.middlewares.matrix-mautrix-bluesky-exposure-strip-prefix.stripprefix.prefixes=/bridges/bluesky-api' in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.http.routers.matrix-mautrix-bluesky-exposure.entrypoints=web' in mautrix_bluesky_labels_rendered"
|
||||
- "'traefik.http.routers.matrix-mautrix-bluesky-exposure.tls=false' in mautrix_bluesky_labels_rendered"
|
||||
- "'molecule.bluesky.coverage=enabled' in mautrix_bluesky_labels_rendered"
|
||||
fail_msg: "The rendered labels do not carry the scenario's exposure configuration"
|
||||
success_msg: "The rendered labels carry the scenario's exposure configuration"
|
||||
|
||||
- name: Inspect the running bridge container
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- container
|
||||
- inspect
|
||||
- matrix-mautrix-bluesky
|
||||
register: mautrix_bluesky_container_inspect
|
||||
changed_when: false
|
||||
|
||||
- name: Parse the running bridge container inspection
|
||||
ansible.builtin.set_fact:
|
||||
mautrix_bluesky_container: "{{ (mautrix_bluesky_container_inspect.stdout | from_json) | first }}"
|
||||
|
||||
- name: Assert the running container uses the exact image pinned by the role
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_container.Config.Image == mautrix_bluesky_expected_image
|
||||
fail_msg: >-
|
||||
The running container uses {{ mautrix_bluesky_container.Config.Image }}, expected
|
||||
{{ mautrix_bluesky_expected_image }}
|
||||
success_msg: "The running container uses the exact image pinned by the role"
|
||||
vars:
|
||||
mautrix_bluesky_expected_image: >-
|
||||
{{ mautrix_bluesky_role_defaults.matrix_bridge_mautrix_bluesky_container_image_registry_prefix_upstream_default }}mautrix/bluesky:{{ mautrix_bluesky_role_defaults.matrix_bridge_mautrix_bluesky_version }}
|
||||
|
||||
- name: Assert the running container uses the playbook-supplied runtime
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_container.Config.User == (matrix_user_uid | string) + ':' + (matrix_user_gid | string)
|
||||
- mautrix_bluesky_container.Config.WorkingDir == '/data'
|
||||
- mautrix_bluesky_container.Config.Cmd == ['/usr/bin/mautrix-bluesky', '-c', '/config/config.yaml', '-r', '/config/registration.yaml', '--no-update']
|
||||
- mautrix_bluesky_container.HostConfig.RestartPolicy.Name == 'no'
|
||||
- mautrix_bluesky_container.HostConfig.AutoRemove
|
||||
- mautrix_bluesky_container.HostConfig.LogConfig.Type == 'none'
|
||||
fail_msg: "The running container does not use the role's exact identity and command"
|
||||
success_msg: "The running container uses the role's exact identity and command"
|
||||
|
||||
- name: Assert the running container has the intended privilege isolation
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'ALL' in mautrix_bluesky_container.HostConfig.CapDrop"
|
||||
- not mautrix_bluesky_container.HostConfig.Privileged
|
||||
fail_msg: "The running container does not have the intended privilege isolation"
|
||||
success_msg: "The running container drops all capabilities and is unprivileged"
|
||||
|
||||
- name: Assert the running container carries the role's exact bind mounts
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_config_mount | length > 0
|
||||
- mautrix_bluesky_config_mount.Source == matrix_bridge_mautrix_bluesky_config_path
|
||||
- not mautrix_bluesky_config_mount.RW
|
||||
- mautrix_bluesky_data_mount | length > 0
|
||||
- mautrix_bluesky_data_mount.Source == matrix_bridge_mautrix_bluesky_data_path
|
||||
- mautrix_bluesky_data_mount.RW
|
||||
- mautrix_bluesky_container.Mounts | length == 2
|
||||
fail_msg: "The running container does not carry the role's exact config and data mounts"
|
||||
success_msg: "The running container carries read-only config and writable data mounts"
|
||||
vars:
|
||||
mautrix_bluesky_config_mount: >-
|
||||
{{ mautrix_bluesky_container.Mounts
|
||||
| selectattr('Destination', 'equalto', '/config')
|
||||
| first | default({}) }}
|
||||
mautrix_bluesky_data_mount: >-
|
||||
{{ mautrix_bluesky_container.Mounts
|
||||
| selectattr('Destination', 'equalto', '/data')
|
||||
| first | default({}) }}
|
||||
|
||||
- name: Assert the rendered labels are attached to the running container
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_container.Config.Labels['traefik.enable'] == 'true'
|
||||
- mautrix_bluesky_container.Config.Labels['traefik.docker.network'] == matrix_bridge_mautrix_bluesky_container_network
|
||||
- mautrix_bluesky_container.Config.Labels['traefik.http.services.matrix-mautrix-bluesky-exposure.loadbalancer.server.port'] == '29340'
|
||||
- mautrix_bluesky_container.Config.Labels['molecule.bluesky.coverage'] == 'enabled'
|
||||
fail_msg: "The running container does not carry the labels the role rendered"
|
||||
success_msg: "The running container carries the labels the role rendered"
|
||||
|
||||
- name: Assert the running container has the exact network and port exposure
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mautrix_bluesky_container.HostConfig.NetworkMode == matrix_bridge_mautrix_bluesky_container_network
|
||||
- matrix_bridge_mautrix_bluesky_container_network in mautrix_bluesky_container.NetworkSettings.Networks
|
||||
- mautrix_bluesky_container.NetworkSettings.Networks | length == 1
|
||||
- mautrix_bluesky_container.HostConfig.PortBindings | default({}, true) | length == 0
|
||||
fail_msg: >-
|
||||
The container has unexpected networks or host ports:
|
||||
networks={{ mautrix_bluesky_container.NetworkSettings.Networks.keys() | list }},
|
||||
ports={{ mautrix_bluesky_container.HostConfig.PortBindings | default({}) }}
|
||||
success_msg: "The container uses only its dedicated network and publishes no host ports"
|
||||
Reference in New Issue
Block a user