Просмотр исходного кода

Keep Beeper Line ghost namespaces in sync

master
Slavi Pantaleev 1 день назад
Родитель
Сommit
c8087f4f20
6 измененных файлов: 24 добавлений и 14 удалений
  1. +1
    -1
      group_vars/matrix_servers
  2. +5
    -2
      roles/custom/matrix-bridge-beeper-line/defaults/main.yml
  3. +2
    -0
      roles/custom/matrix-bridge-beeper-line/molecule/default/molecule.yml
  4. +12
    -9
      roles/custom/matrix-bridge-beeper-line/molecule/default/verify.yml
  5. +3
    -1
      roles/custom/matrix-bridge-beeper-line/tasks/validate_config.yml
  6. +1
    -1
      roles/custom/matrix-bridge-beeper-line/templates/config.yaml.j2

+ 1
- 1
group_vars/matrix_servers Просмотреть файл

@@ -5368,7 +5368,7 @@ matrix_ketesa_config_asManagedUsers_auto: |
+ +
([ ([
'^@'+(matrix_bridge_beeper_line_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', '^@'+(matrix_bridge_beeper_line_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$',
'^@line_[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$',
'^@'+(matrix_bridge_beeper_line_appservice_username_prefix | default('') | regex_escape)+'[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$',
] if matrix_bridge_beeper_line_enabled else []) ] if matrix_bridge_beeper_line_enabled else [])
+ +
([ ([


+ 5
- 2
roles/custom/matrix-bridge-beeper-line/defaults/main.yml Просмотреть файл

@@ -165,7 +165,10 @@ matrix_bridge_beeper_line_bridge_encryption_appservice: false
matrix_bridge_beeper_line_bridge_encryption_key_sharing_allow: "{{ matrix_bridge_beeper_line_bridge_encryption_allow }}" matrix_bridge_beeper_line_bridge_encryption_key_sharing_allow: "{{ matrix_bridge_beeper_line_bridge_encryption_allow }}"
matrix_bridge_beeper_line_bridge_encryption_pickle_key: mautrix.bridge.e2ee matrix_bridge_beeper_line_bridge_encryption_pickle_key: mautrix.bridge.e2ee


matrix_bridge_beeper_line_appservice_username_template: "{% raw %}line_{{.}}{% endraw %}"
# Prefix of the localparts generated for LINE ghost users.
# The bridge username template, appservice registration namespace, and Ketesa managed-user
# allowlist are all derived from this value.
matrix_bridge_beeper_line_appservice_username_prefix: line_


# Shared secret for authentication of provisioning API requests. # Shared secret for authentication of provisioning API requests.
# If set to "disable", the provisioning API will be disabled. # If set to "disable", the provisioning API will be disabled.
@@ -210,7 +213,7 @@ matrix_bridge_beeper_line_registration_yaml: |
rate_limited: false rate_limited: false
namespaces: namespaces:
users: users:
- regex: '^@line_.+:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$'
- regex: '^@{{ matrix_bridge_beeper_line_appservice_username_prefix | regex_escape }}.+:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$'
exclusive: true exclusive: true
- exclusive: true - exclusive: true
regex: '^@{{ matrix_bridge_beeper_line_appservice_bot_username | regex_escape }}:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$' regex: '^@{{ matrix_bridge_beeper_line_appservice_bot_username | regex_escape }}:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$'


+ 2
- 0
roles/custom/matrix-bridge-beeper-line/molecule/default/molecule.yml Просмотреть файл

@@ -47,6 +47,8 @@ provisioner:
matrix_bridge_beeper_line_appservice_bot_username: molecule-linebot matrix_bridge_beeper_line_appservice_bot_username: molecule-linebot
matrix_bridge_beeper_line_appservice_bot_displayname: Molecule LINE Bot matrix_bridge_beeper_line_appservice_bot_displayname: Molecule LINE Bot
matrix_bridge_beeper_line_appservice_bot_avatar: mxc://molecule.local/lineAvatarFixture matrix_bridge_beeper_line_appservice_bot_avatar: mxc://molecule.local/lineAvatarFixture
# The dot proves every consumer escapes the shared non-default prefix as a regex.
matrix_bridge_beeper_line_appservice_username_prefix: molecule.line_
# Each value differs from the role default so parsed checks distinguish role output # Each value differs from the role default so parsed checks distinguish role output
# from component defaults. # from component defaults.
matrix_bridge_beeper_line_command_prefix: "!molecule-line" matrix_bridge_beeper_line_command_prefix: "!molecule-line"


+ 12
- 9
roles/custom/matrix-bridge-beeper-line/molecule/default/verify.yml Просмотреть файл

@@ -179,6 +179,7 @@
- beeper_line_config.appservice.bot.avatar == matrix_bridge_beeper_line_appservice_bot_avatar - beeper_line_config.appservice.bot.avatar == matrix_bridge_beeper_line_appservice_bot_avatar
- beeper_line_config.appservice.as_token == matrix_bridge_beeper_line_appservice_token - beeper_line_config.appservice.as_token == matrix_bridge_beeper_line_appservice_token
- beeper_line_config.appservice.hs_token == matrix_bridge_beeper_line_homeserver_token - beeper_line_config.appservice.hs_token == matrix_bridge_beeper_line_homeserver_token
- beeper_line_config.appservice.username_template == matrix_bridge_beeper_line_appservice_username_prefix + '{' + '{.}' + '}'
fail_msg: "The rendered configuration does not carry the scenario's appservice identity" fail_msg: "The rendered configuration does not carry the scenario's appservice identity"
success_msg: "The rendered configuration carries the scenario's appservice identity" success_msg: "The rendered configuration carries the scenario's appservice identity"


@@ -233,21 +234,23 @@
fail_msg: "The registration does not carry the configured handshake values" fail_msg: "The registration does not carry the configured handshake values"
success_msg: "The registration carries the configured handshake values" success_msg: "The registration carries the configured handshake values"


- name: Assert the registration namespaces cover only LINE ghosts and the bridge bot
- name: Assert the registration namespaces use the shared LINE ghost prefix and cover the bridge bot
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- beeper_line_ghost_regex | length > 0
- beeper_line_bot_regex | length > 0
- beeper_line_registration.namespaces.users | length == 2
- beeper_line_ghost_regex == beeper_line_expected_ghost_regex
- beeper_line_bot_regex == beeper_line_expected_bot_regex
- beeper_line_ghost_mxid is match(beeper_line_ghost_regex) - beeper_line_ghost_mxid is match(beeper_line_ghost_regex)
- beeper_line_wrong_ghost_mxid is not match(beeper_line_ghost_regex) - beeper_line_wrong_ghost_mxid is not match(beeper_line_ghost_regex)
- beeper_line_bot_mxid is match(beeper_line_bot_regex) - beeper_line_bot_mxid is match(beeper_line_bot_regex)
fail_msg: "The registration namespaces do not cover only LINE ghosts and the bot"
success_msg: "The registration namespaces cover only LINE ghosts and the bot"
fail_msg: "The registration namespaces do not use the shared LINE ghost prefix or cover the bot"
success_msg: "The registration namespaces use the shared LINE ghost prefix and cover the bot"
vars: vars:
beeper_line_user_regexes: "{{ beeper_line_registration.namespaces.users | map(attribute='regex') | list }}"
beeper_line_ghost_regex: "{{ beeper_line_user_regexes | select('search', 'line_') | first | default('') }}"
beeper_line_bot_regex: "{{ beeper_line_user_regexes | reject('search', 'line_') | first | default('') }}"
beeper_line_ghost_mxid: "@line_moleculefixture:{{ matrix_bridge_beeper_line_homeserver_domain }}"
beeper_line_ghost_regex: "{{ beeper_line_registration.namespaces.users[0].regex }}"
beeper_line_bot_regex: "{{ beeper_line_registration.namespaces.users[1].regex }}"
beeper_line_expected_ghost_regex: '^@{{ matrix_bridge_beeper_line_appservice_username_prefix | regex_escape }}.+:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$'
beeper_line_expected_bot_regex: '^@{{ matrix_bridge_beeper_line_appservice_bot_username | regex_escape }}:{{ matrix_bridge_beeper_line_homeserver_domain | regex_escape }}$'
beeper_line_ghost_mxid: "@{{ matrix_bridge_beeper_line_appservice_username_prefix }}moleculefixture:{{ matrix_bridge_beeper_line_homeserver_domain }}"
beeper_line_wrong_ghost_mxid: "@twitter_moleculefixture:{{ matrix_bridge_beeper_line_homeserver_domain }}" beeper_line_wrong_ghost_mxid: "@twitter_moleculefixture:{{ matrix_bridge_beeper_line_homeserver_domain }}"
beeper_line_bot_mxid: "@{{ matrix_bridge_beeper_line_appservice_bot_username }}:{{ matrix_bridge_beeper_line_homeserver_domain }}" beeper_line_bot_mxid: "@{{ matrix_bridge_beeper_line_appservice_bot_username }}:{{ matrix_bridge_beeper_line_homeserver_domain }}"




+ 3
- 1
roles/custom/matrix-bridge-beeper-line/tasks/validate_config.yml Просмотреть файл

@@ -11,7 +11,8 @@
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml). Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml).
when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0" when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0"
with_items: []
with_items:
- {'old': 'matrix_bridge_beeper_line_appservice_username_template', 'new': 'matrix_bridge_beeper_line_appservice_username_prefix'}


- name: Fail if required beeper-line settings not defined - name: Fail if required beeper-line settings not defined
ansible.builtin.fail: ansible.builtin.fail:
@@ -22,5 +23,6 @@
- {'name': 'matrix_bridge_beeper_line_appservice_token', when: true} - {'name': 'matrix_bridge_beeper_line_appservice_token', when: true}
- {'name': 'matrix_bridge_beeper_line_homeserver_address', when: true} - {'name': 'matrix_bridge_beeper_line_homeserver_address', when: true}
- {'name': 'matrix_bridge_beeper_line_homeserver_token', when: true} - {'name': 'matrix_bridge_beeper_line_homeserver_token', when: true}
- {'name': 'matrix_bridge_beeper_line_appservice_username_prefix', when: true}
- {'name': 'matrix_bridge_beeper_line_database_hostname', when: "{{ matrix_bridge_beeper_line_database_engine == 'postgres' }}"} - {'name': 'matrix_bridge_beeper_line_database_hostname', when: "{{ matrix_bridge_beeper_line_database_engine == 'postgres' }}"}
- {'name': 'matrix_bridge_beeper_line_container_network', when: true} - {'name': 'matrix_bridge_beeper_line_container_network', when: true}

+ 1
- 1
roles/custom/matrix-bridge-beeper-line/templates/config.yaml.j2 Просмотреть файл

@@ -250,7 +250,7 @@ appservice:


# Localpart template of MXIDs for remote users. # Localpart template of MXIDs for remote users.
# {% raw %}{{.}}{% endraw %} is replaced with the internal ID of the user. # {% raw %}{{.}}{% endraw %} is replaced with the internal ID of the user.
username_template: {{ matrix_bridge_beeper_line_appservice_username_template | to_json }}
username_template: {{ (matrix_bridge_beeper_line_appservice_username_prefix + '{{.}}') | to_json }}


# Config options that affect the Matrix connector of the bridge. # Config options that affect the Matrix connector of the bridge.
matrix: matrix:


Загрузка…
Отмена
Сохранить