Adding molecule unit tests

This commit is contained in:
Ian Roddis
2026-03-23 15:15:27 -03:00
parent 72f171e88f
commit 0bf5dd0024
75 changed files with 2092 additions and 2 deletions
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: localhost
gather_facts: false
vars_files:
- ../../../molecule/shared/vars.yml
roles:
- role: roundcube
@@ -0,0 +1,23 @@
---
dependency:
name: galaxy
options:
requirements-file: requirements.yml
driver:
name: delegated
options:
managed: false
ansible_connection_options:
ansible_connection: local
platforms:
- name: localhost
groups:
- sovereign
provisioner:
name: ansible
inventory:
host_vars:
localhost:
ansible_connection: local
verifier:
name: ansible
@@ -0,0 +1,95 @@
---
- name: Verify roundcube role
hosts: localhost
gather_facts: false
vars:
roundcube_data_dir: /tmp/sovereign_test/roundcube
tasks:
- name: Check roundcube data directory exists
ansible.builtin.stat:
path: /tmp/sovereign_test/roundcube
register: data_dir_stat
- name: Assert roundcube data directory is present
ansible.builtin.assert:
that: data_dir_stat.stat.isdir
fail_msg: "Data directory /tmp/sovereign_test/roundcube was not created"
- name: Check roundcube config directory exists
ansible.builtin.stat:
path: /tmp/sovereign_test/roundcube/config
register: config_dir_stat
- name: Assert roundcube config directory is present
ansible.builtin.assert:
that: config_dir_stat.stat.isdir
fail_msg: "Directory /tmp/sovereign_test/roundcube/config was not created"
- name: Check custom.inc.php exists
ansible.builtin.stat:
path: /tmp/sovereign_test/roundcube/config/custom.inc.php
register: custom_php_stat
- name: Assert custom.inc.php is present
ansible.builtin.assert:
that: custom_php_stat.stat.exists
fail_msg: "custom.inc.php was not rendered for roundcube"
- name: Read custom.inc.php
ansible.builtin.slurp:
src: /tmp/sovereign_test/roundcube/config/custom.inc.php
register: custom_php_raw
- name: Set custom.inc.php content fact
ansible.builtin.set_fact:
custom_php: "{{ custom_php_raw.content | b64decode }}"
- name: Assert tenant branding in custom.inc.php
ansible.builtin.assert:
that: "'Test Corp Webmail' in custom_php"
fail_msg: "Expected 'Test Corp Webmail' not found in custom.inc.php"
- name: Check docker-compose.yml exists
ansible.builtin.stat:
path: /tmp/sovereign_test/roundcube/docker-compose.yml
register: compose_stat
- name: Assert docker-compose.yml was rendered
ansible.builtin.assert:
that: compose_stat.stat.exists
fail_msg: "docker-compose.yml was not rendered for roundcube"
- name: Read docker-compose.yml
ansible.builtin.slurp:
src: /tmp/sovereign_test/roundcube/docker-compose.yml
register: compose_raw
- name: Set compose content fact
ansible.builtin.set_fact:
compose: "{{ compose_raw.content | b64decode }}"
- name: Assert roundcube image reference in compose
ansible.builtin.assert:
that: "'roundcube/roundcubemail' in compose"
fail_msg: "Expected image 'roundcube/roundcubemail' not found in docker-compose.yml"
- name: Assert roundcube host rule in compose
ansible.builtin.assert:
that: "'Host(`webmail.test.example.com`)' in compose"
fail_msg: "Expected Host rule for webmail.test.example.com not found in docker-compose.yml"
- name: Assert GELF logging address in compose
ansible.builtin.assert:
that: "'udp://127.0.0.1:12201' in compose"
fail_msg: "Expected GELF address udp://127.0.0.1:12201 not found in docker-compose.yml"
- name: Assert sovereign network is external in compose
ansible.builtin.assert:
that: "'external: true' in compose"
fail_msg: "Expected 'external: true' not found in docker-compose.yml"
- name: Assert roundcube skin (elastic) in compose
ansible.builtin.assert:
that: "'elastic' in compose"
fail_msg: "Expected roundcube skin 'elastic' not found in docker-compose.yml"