summaryrefslogtreecommitdiffstats
path: root/ansible_collections/sensu/sensu_go/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/sensu/sensu_go/tests
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/sensu/sensu_go/tests')
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/base.yml5
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/action_bonsai_asset/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/converge.yml14
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/molecule.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_cert/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ad_auth_provider/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_asset/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_check/converge.yml10
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role_binding/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_datastore/converge.yml65
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_entity/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_event/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_filter/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_handler_set/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_hook/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ldap_auth_provider/converge.yml12
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_mutator/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_namespace/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_oidc_auth_provider/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipe_handler/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/converge.yml502
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/molecule.yml31
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role_binding/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_env/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_vault/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_silence/converge.yml6
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_socket_handler/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_tessen/converge.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/module_user/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_default/molecule.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/molecule.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_config/converge.yml4
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_default/verify.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_build/molecule.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_version/molecule.yml2
-rw-r--r--ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_default_deb/molecule.yml5
-rw-r--r--ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_datastore.py83
-rw-r--r--ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline.py179
-rw-r--r--ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline_info.py63
-rw-r--r--ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_user.py45
43 files changed, 1042 insertions, 72 deletions
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/base.yml b/ansible_collections/sensu/sensu_go/tests/integration/base.yml
index 396c4ebfe..f36dfdcb1 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/base.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/base.yml
@@ -17,6 +17,11 @@ provisioner:
lint:
enabled: false
platforms:
+ - name: v6.10.0
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.10.0
+ pre_build_image: true
+ pull: true
+ override_command: false
- name: v6.9.0
image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.9.0
pre_build_image: true
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/action_bonsai_asset/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/action_bonsai_asset/converge.yml
index ceeb3bdcd..f2bcfcfcc 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/action_bonsai_asset/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/action_bonsai_asset/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a Bonsai asset
bonsai_asset: &idempotence
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/converge.yml
index 5cc1fb19f..7f4e9f17f 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/converge.yml
@@ -1,7 +1,7 @@
---
- name: Prepare new backend
hosts: has_api_key_support
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a regular user
@@ -13,14 +13,14 @@
sensu.sensu_go.role:
name: test_role
rules:
- - verbs: [ list ]
- resources: [ assets ]
+ - verbs: [list]
+ resources: [assets]
- name: Allow user to list entities
sensu.sensu_go.role_binding:
name: test_binding
role: test_role
- users: [ test_user ]
+ users: [test_user]
- name: Configure sensuctl
command:
@@ -59,7 +59,7 @@
hosts: has_api_key_support
collections:
- sensu.sensu_go
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fail with invalid password
@@ -201,7 +201,7 @@
- name: Prepare old backend
hosts: no_api_key_support
- gather_facts: no
+ gather_facts: false
tasks:
- name: Configure sensuctl
@@ -226,7 +226,7 @@
hosts: no_api_key_support
collections:
- sensu.sensu_go
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fail with invalid password
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/molecule.yml
index 1648fc459..7a10e2e4f 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_authentication/molecule.yml
@@ -1,13 +1,13 @@
platforms:
- name: v6.4.1
image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.4.1
- groups: [ has_api_key_support ]
+ groups: [has_api_key_support]
pre_build_image: true
pull: true
override_command: false
- name: v5.14.2
image: quay.io/xlab-steampunk/sensu-go-tests-sensu:5.14.2
- groups: [ no_api_key_support ]
+ groups: [no_api_key_support]
pre_build_image: true
pull: true
override_command: false
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_cert/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_cert/converge.yml
index a0867bb32..b8873291a 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_cert/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/misc_api_cert/converge.yml
@@ -1,7 +1,7 @@
---
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Test connection using no verification
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ad_auth_provider/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ad_auth_provider/converge.yml
index 0112074b9..9080af7d0 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ad_auth_provider/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ad_auth_provider/converge.yml
@@ -1,7 +1,7 @@
---
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all AD auth providers and verify the presence
sensu.sensu_go.auth_provider_info:
@@ -143,7 +143,7 @@
- result.objects.0.groups_prefix == 'dev'
- name: Idempotence check for AD auth provider modification
- sensu.sensu_go.ad_auth_provider: *update-provider
+ sensu.sensu_go.ad_auth_provider: *update-provider
register: result
- ansible.builtin.assert:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_asset/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_asset/converge.yml
index 062ab7ee0..133723415 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_asset/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_asset/converge.yml
@@ -1,7 +1,7 @@
---
- name: Setup sensuctl
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Configure sensuctl
@@ -19,7 +19,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create an asset with missing required parameters
asset:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_check/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_check/converge.yml
index 645ebe644..d0f0b8aa2 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_check/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_check/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a check with missing required parameters
check:
@@ -64,20 +64,20 @@
- default
- not_default
interval: 30
- publish: True
+ publish: true
timeout: 30
ttl: 100
- stdin: False
+ stdin: false
low_flap_threshold: 20
high_flap_threshold: 60
proxy_entity_name: switch-dc-01
proxy_requests:
entity_attributes: ['entity.entity_class == "proxy"']
- splay: True
+ splay: true
splay_coverage: 90
output_metric_format: nagios_perfdata
output_metric_handlers: ['influx-db']
- round_robin: True
+ round_robin: true
env_vars:
foo: bar
runtime_assets: awesomeness
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role/converge.yml
index b771c76d3..02f730ec2 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a cluster role with missing required parameters
cluster_role:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role_binding/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role_binding/converge.yml
index 5fbb40def..164ac1d73 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role_binding/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_cluster_role_binding/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a cluster role binding with missing required parameters
cluster_role_binding:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_datastore/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_datastore/converge.yml
index a6963f973..097045e7d 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_datastore/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_datastore/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Retrieve empty list of external datastores
datastore_info:
@@ -103,6 +103,69 @@
name: my-datastore
state: absent
+ - name: Enable external datastore with all parameters
+ datastore: &idempotence_2
+ auth: *auth
+ name: my-datastore
+ dsn: postgresql://user:secret@host:port/dbname
+ pool_size: 1
+ max_conn_lifetime: "5m"
+ max_idle_conns: 3
+ batch_workers: 2
+ batch_buffer: 1
+ batch_size: 2
+ enable_round_robin: true
+ strict: false
+ register: result
+
+ - assert:
+ that:
+ - result is changed
+ - result.object.metadata.name == "my-datastore"
+ - result.object.dsn == "postgresql://user:secret@host:port/dbname"
+ - result.object.pool_size == 1
+ - result.object.max_conn_lifetime == "5m"
+ - result.object.max_idle_conns == 3
+ - result.object.batch_workers == 2
+ - result.object.batch_buffer == 1
+ - result.object.batch_size == 2
+ - result.object.enable_round_robin is true
+ - result.object.strict is false
+
+ - name: Check for idempotence
+ datastore: *idempotence_2
+ register: result
+
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Fetch datastore with all parameters
+ datastore_info:
+ auth: *auth
+ name: my-datastore
+ register: result
+
+ - assert:
+ that:
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "my-datastore"
+ - result.objects.0.dsn == "postgresql://user:secret@host:port/dbname"
+ - result.objects.0.pool_size == 1
+ - result.objects.0.max_conn_lifetime == "5m"
+ - result.objects.0.max_idle_conns == 3
+ - result.objects.0.batch_workers == 2
+ - result.objects.0.batch_buffer == 1
+ - result.objects.0.batch_size == 2
+ - result.objects.0.enable_round_robin is true
+ - result.objects.0.strict is false
+
+ - name: Remove external datastore
+ datastore:
+ auth: *auth
+ name: my-datastore
+ state: absent
+
- name: Re-fetch all datastores
datastore_info:
auth: *auth
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_entity/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_entity/converge.yml
index 4cca68495..351ddd7d5 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_entity/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_entity/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create entity with minimal parameters
entity:
@@ -55,7 +55,7 @@
addresses:
- 93.184.216.34/24
last_seen: 1522798317
- deregister: yes
+ deregister: true
deregistration_handler: email-handler
redact:
- password
@@ -102,7 +102,7 @@
addresses:
- 93.184.216.34/24
last_seen: 1522798317
- deregister: yes
+ deregister: true
deregistration_handler: email-handler
redact:
- password
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_event/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_event/converge.yml
index 885698e1e..a92fad7c3 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_event/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_event/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Event info without entity
event_info:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_filter/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_filter/converge.yml
index 6ae4f03a2..1c0353a4f 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_filter/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_filter/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create filter with missing required parameters
filter:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_handler_set/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_handler_set/converge.yml
index 5a71e7e9e..93e2cc361 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_handler_set/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_handler_set/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create handler set
handler_set:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_hook/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_hook/converge.yml
index 160c27d62..eb22ed3dd 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_hook/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_hook/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create hook with minimal parameters
hook:
@@ -40,7 +40,7 @@
name: hook
command: /bin/true
timeout: 30
- stdin: yes
+ stdin: true
runtime_assets:
- ruby2.4
register: result
@@ -61,7 +61,7 @@
name: hook
command: /bin/true
timeout: 30
- stdin: yes
+ stdin: true
runtime_assets:
- ruby2.4
register: result
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ldap_auth_provider/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ldap_auth_provider/converge.yml
index 053bdf82d..451a70073 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ldap_auth_provider/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_ldap_auth_provider/converge.yml
@@ -1,7 +1,7 @@
---
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all LDAP auth providers and verify the presence
sensu.sensu_go.auth_provider_info:
@@ -11,7 +11,7 @@
- ansible.builtin.assert:
that:
- - result.objects | length == 0
+ - result.objects | length == 0
- name: Fail when trying to create a LDAP auth provider with missing required params
sensu.sensu_go.ldap_auth_provider:
@@ -30,7 +30,7 @@
sensu.sensu_go.ldap_auth_provider: &create-provider
state: present
name: openldap
- servers:
+ servers:
- host: 127.0.0.1
group_search:
base_dn: dc=acme,dc=org
@@ -87,7 +87,7 @@
sensu.sensu_go.ldap_auth_provider: &update-provider
state: present
name: openldap
- servers:
+ servers:
- host: 127.0.0.1
group_search:
base_dn: dc=acme,dc=org
@@ -143,7 +143,7 @@
- result.objects.0.groups_prefix == 'dev'
- name: Idempotence check for LDAP auth provider modification
- sensu.sensu_go.ldap_auth_provider: *update-provider
+ sensu.sensu_go.ldap_auth_provider: *update-provider
register: result
- ansible.builtin.assert:
@@ -222,7 +222,7 @@
url: http://localhost:8080
state: present
name: other-openldap
- servers:
+ servers:
- host: 127.0.0.1
port: 636
insecure: false
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_mutator/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_mutator/converge.yml
index 52db18f85..0c3ba83cb 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_mutator/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_mutator/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create mutator with minimal parameters
mutator:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_namespace/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_namespace/converge.yml
index e7f332e2f..1642d2906 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_namespace/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_namespace/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all namespaces
namespace_info:
@@ -55,7 +55,7 @@
- result.objects | length == expected_length | int
- result.objects.1.name == 'dev'
vars:
- expected_length: "{{ starting_length|int + 2 }}"
+ expected_length: "{{ starting_length | int + 2 }}"
- name: Delete namespace
namespace:
@@ -75,4 +75,4 @@
- result.objects | length == expected_length | int
- result.objects.1.name == 'production'
vars:
- expected_length: "{{ starting_length|int + 1 }}"
+ expected_length: "{{ starting_length | int + 1 }}"
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_oidc_auth_provider/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_oidc_auth_provider/converge.yml
index 89f42f48a..551989376 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_oidc_auth_provider/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_oidc_auth_provider/converge.yml
@@ -1,7 +1,7 @@
---
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all auth providers and verify the presence
sensu.sensu_go.auth_provider_info:
@@ -11,7 +11,7 @@
- ansible.builtin.assert:
that:
- - result.objects | length == 0
+ - result.objects | length == 0
- name: Fail when trying to create a OIDC auth provider with missing required params
sensu.sensu_go.oidc_auth_provider:
@@ -146,7 +146,7 @@
- result.objects.0.username_claim == 'email'
- name: Idempotence check for OIDC auth provider modification
- sensu.sensu_go.oidc_auth_provider: *update-provider
+ sensu.sensu_go.oidc_auth_provider: *update-provider
register: result
- ansible.builtin.assert:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipe_handler/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipe_handler/converge.yml
index 8fe9f0682..fa322c2b0 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipe_handler/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipe_handler/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create pipe handler with minimal parameters
pipe_handler:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/converge.yml
new file mode 100644
index 000000000..1a88482b5
--- /dev/null
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/converge.yml
@@ -0,0 +1,502 @@
+---
+- name: Converge
+ collections:
+ - sensu.sensu_go
+ hosts: all
+ gather_facts: no
+ vars:
+ SENSU_URL: http://localhost:8080
+ tasks:
+ - name: Create pipeline with minimal parameters
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.object.metadata.name == "pipeline_integration_test"
+ - result.object.metadata.namespace == "default"
+ - result.object.metadata.created_by == "admin"
+ - result.object.workflows | length == 1
+ - result.object.workflows.0.name == "this_wf"
+ - result.object.workflows.0.handler.name == "this_handler"
+ - result.object.workflows.0.handler.type == "Handler"
+
+ - name: Get data with info module - test info module
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ register: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 1
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+
+ - name: Create pipeline with minimal parameters - IDEMPOTENCE
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Check that idempotence didn't change anything
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ register: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 1
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+
+ - name: Create pipeline with all parameters
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ - name: this_wf_2
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.object.metadata.name == "pipeline_integration_test_2"
+ - result.object.metadata.namespace == "default"
+ - result.object.metadata.created_by == "admin"
+ - result.object.workflows | length == 2
+ - result.object.workflows.0.name == "this_wf"
+ - result.object.workflows.0.handler.name == "this_handler"
+ - result.object.workflows.0.handler.type == "Handler"
+ - result.object.workflows.0.filters | length == 2
+ - result.object.workflows.0.filters.0.name == "this_filter_1"
+ - result.object.workflows.0.filters.0.type == "EventFilter"
+ - result.object.workflows.0.filters.1.name == "this_filter_2"
+ - result.object.workflows.0.filters.1.type == "EventFilter"
+ - result.object.workflows.0.mutator.name == "this_mutator"
+ - result.object.workflows.0.mutator.type == "Mutator"
+ - result.object.workflows.1.name == "this_wf_2"
+ - result.object.workflows.1.handler.name == "this_handler"
+ - result.object.workflows.1.handler.type == "Handler"
+ - result.object.workflows.1.filters | length == 2
+ - result.object.workflows.1.filters.0.name == "this_filter_1"
+ - result.object.workflows.1.filters.0.type == "EventFilter"
+ - result.object.workflows.1.filters.1.name == "this_filter_2"
+ - result.object.workflows.1.filters.1.type == "EventFilter"
+ - result.object.workflows.1.mutator.name == "this_mutator"
+ - result.object.workflows.1.mutator.type == "Mutator"
+
+ - name: Get data with info module - test two pipelines
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ register: result
+ - name: Show uploaded certificate info
+ ansible.builtin.debug:
+ var: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 2
+ - result.objects.0.metadata.name == "pipeline_integration_test"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 1
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.1.metadata.name == "pipeline_integration_test_2"
+ - result.objects.1.metadata.namespace == "default"
+ - result.objects.1.metadata.created_by == "admin"
+ - result.objects.1.workflows | length == 2
+ - result.objects.1.workflows.0.name == "this_wf"
+ - result.objects.1.workflows.0.handler.name == "this_handler"
+ - result.objects.1.workflows.0.handler.type == "Handler"
+ - result.objects.1.workflows.0.filters | length == 2
+ - result.objects.1.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.1.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.1.workflows.0.filters.1.name == "this_filter_2"
+ - result.objects.1.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.1.workflows.0.mutator.name == "this_mutator"
+ - result.objects.1.workflows.0.mutator.type == "Mutator"
+ - result.objects.1.workflows.1.name == "this_wf_2"
+ - result.objects.1.workflows.1.handler.name == "this_handler"
+ - result.objects.1.workflows.1.handler.type == "Handler"
+ - result.objects.1.workflows.1.filters | length == 2
+ - result.objects.1.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.1.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.1.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.1.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.1.workflows.1.mutator.name == "this_mutator"
+ - result.objects.1.workflows.1.mutator.type == "Mutator"
+
+ - name: Create pipeline with all parameters - IDEMPOTENCE
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ - name: this_wf_2
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Check that idempotence didn't change anything - test two pipelines
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ register: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 2
+ - result.objects.0.metadata.name == "pipeline_integration_test"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 1
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.1.metadata.name == "pipeline_integration_test_2"
+ - result.objects.1.metadata.namespace == "default"
+ - result.objects.1.metadata.created_by == "admin"
+ - result.objects.1.workflows | length == 2
+ - result.objects.1.workflows.0.name == "this_wf"
+ - result.objects.1.workflows.0.handler.name == "this_handler"
+ - result.objects.1.workflows.0.handler.type == "Handler"
+ - result.objects.1.workflows.0.filters | length == 2
+ - result.objects.1.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.1.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.1.workflows.0.filters.1.name == "this_filter_2"
+ - result.objects.1.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.1.workflows.0.mutator.name == "this_mutator"
+ - result.objects.1.workflows.0.mutator.type == "Mutator"
+ - result.objects.1.workflows.1.name == "this_wf_2"
+ - result.objects.1.workflows.1.handler.name == "this_handler"
+ - result.objects.1.workflows.1.handler.type == "Handler"
+ - result.objects.1.workflows.1.filters | length == 2
+ - result.objects.1.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.1.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.1.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.1.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.1.workflows.1.mutator.name == "this_mutator"
+ - result.objects.1.workflows.1.mutator.type == "Mutator"
+
+ - name: Change filter name on 2nd pipeline
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2_changed
+ mutator:
+ name: this_mutator
+ - name: this_wf_2
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.object.metadata.name == "pipeline_integration_test_2"
+ - result.object.metadata.namespace == "default"
+ - result.object.metadata.created_by == "admin"
+ - result.object.workflows | length == 2
+ - result.object.workflows.0.name == "this_wf"
+ - result.object.workflows.0.handler.name == "this_handler"
+ - result.object.workflows.0.handler.type == "Handler"
+ - result.object.workflows.0.filters | length == 2
+ - result.object.workflows.0.filters.0.name == "this_filter_1"
+ - result.object.workflows.0.filters.0.type == "EventFilter"
+ - result.object.workflows.0.filters.1.name == "this_filter_2_changed"
+ - result.object.workflows.0.filters.1.type == "EventFilter"
+ - result.object.workflows.0.mutator.name == "this_mutator"
+ - result.object.workflows.0.mutator.type == "Mutator"
+ - result.object.workflows.1.name == "this_wf_2"
+ - result.object.workflows.1.handler.name == "this_handler"
+ - result.object.workflows.1.handler.type == "Handler"
+ - result.object.workflows.1.filters | length == 2
+ - result.object.workflows.1.filters.0.name == "this_filter_1"
+ - result.object.workflows.1.filters.0.type == "EventFilter"
+ - result.object.workflows.1.filters.1.name == "this_filter_2"
+ - result.object.workflows.1.filters.1.type == "EventFilter"
+ - result.object.workflows.1.mutator.name == "this_mutator"
+ - result.object.workflows.1.mutator.type == "Mutator"
+
+ - name: Get data with info module - test change
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ register: result
+ - name: Show uploaded certificate info
+ ansible.builtin.debug:
+ var: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test_2"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 2
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.0.workflows.0.filters | length == 2
+ - result.objects.0.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.0.filters.1.name == "this_filter_2_changed"
+ - result.objects.0.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.0.mutator.name == "this_mutator"
+ - result.objects.0.workflows.0.mutator.type == "Mutator"
+ - result.objects.0.workflows.1.name == "this_wf_2"
+ - result.objects.0.workflows.1.handler.name == "this_handler"
+ - result.objects.0.workflows.1.handler.type == "Handler"
+ - result.objects.0.workflows.1.filters | length == 2
+ - result.objects.0.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.0.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.1.mutator.name == "this_mutator"
+ - result.objects.0.workflows.1.mutator.type == "Mutator"
+
+ - name: Change filter name on 2nd pipeline - IDEMPOTENCE
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ workflows:
+ - name: this_wf
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2_changed
+ mutator:
+ name: this_mutator
+ - name: this_wf_2
+ handler:
+ name: this_handler
+ type: handler
+ filters:
+ - name: this_filter_1
+ - name: this_filter_2
+ mutator:
+ name: this_mutator
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Check that idempotence didn't change anything
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test_2
+ register: result
+ - name: Show uploaded certificate info
+ ansible.builtin.debug:
+ var: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test_2"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 2
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.0.workflows.0.filters | length == 2
+ - result.objects.0.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.0.filters.1.name == "this_filter_2_changed"
+ - result.objects.0.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.0.mutator.name == "this_mutator"
+ - result.objects.0.workflows.0.mutator.type == "Mutator"
+ - result.objects.0.workflows.1.name == "this_wf_2"
+ - result.objects.0.workflows.1.handler.name == "this_handler"
+ - result.objects.0.workflows.1.handler.type == "Handler"
+ - result.objects.0.workflows.1.filters | length == 2
+ - result.objects.0.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.0.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.1.mutator.name == "this_mutator"
+ - result.objects.0.workflows.1.mutator.type == "Mutator"
+
+ - name: Delete first pipeline
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Get data with info module - check delete
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ register: result
+ - name: Show uploaded certificate info
+ ansible.builtin.debug:
+ var: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test_2"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 2
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.0.workflows.0.filters | length == 2
+ - result.objects.0.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.0.filters.1.name == "this_filter_2_changed"
+ - result.objects.0.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.0.mutator.name == "this_mutator"
+ - result.objects.0.workflows.0.mutator.type == "Mutator"
+ - result.objects.0.workflows.1.name == "this_wf_2"
+ - result.objects.0.workflows.1.handler.name == "this_handler"
+ - result.objects.0.workflows.1.handler.type == "Handler"
+ - result.objects.0.workflows.1.filters | length == 2
+ - result.objects.0.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.0.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.1.mutator.name == "this_mutator"
+ - result.objects.0.workflows.1.mutator.type == "Mutator"
+
+ - name: Delete first pipeline - IDEMPOTENCE
+ pipeline:
+ auth:
+ url: "{{ SENSU_URL }}"
+ name: pipeline_integration_test
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Check that idempotence didn't change anything
+ pipeline_info:
+ auth:
+ url: "{{ SENSU_URL }}"
+ register: result
+ - name: Show uploaded certificate info
+ ansible.builtin.debug:
+ var: result
+ - assert:
+ that:
+ - result is not changed
+ - result.objects | length == 1
+ - result.objects.0.metadata.name == "pipeline_integration_test_2"
+ - result.objects.0.metadata.namespace == "default"
+ - result.objects.0.metadata.created_by == "admin"
+ - result.objects.0.workflows | length == 2
+ - result.objects.0.workflows.0.name == "this_wf"
+ - result.objects.0.workflows.0.handler.name == "this_handler"
+ - result.objects.0.workflows.0.handler.type == "Handler"
+ - result.objects.0.workflows.0.filters | length == 2
+ - result.objects.0.workflows.0.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.0.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.0.filters.1.name == "this_filter_2_changed"
+ - result.objects.0.workflows.0.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.0.mutator.name == "this_mutator"
+ - result.objects.0.workflows.0.mutator.type == "Mutator"
+ - result.objects.0.workflows.1.name == "this_wf_2"
+ - result.objects.0.workflows.1.handler.name == "this_handler"
+ - result.objects.0.workflows.1.handler.type == "Handler"
+ - result.objects.0.workflows.1.filters | length == 2
+ - result.objects.0.workflows.1.filters.0.name == "this_filter_1"
+ - result.objects.0.workflows.1.filters.0.type == "EventFilter"
+ - result.objects.0.workflows.1.filters.1.name == "this_filter_2"
+ - result.objects.0.workflows.1.filters.1.type == "EventFilter"
+ - result.objects.0.workflows.1.mutator.name == "this_mutator"
+ - result.objects.0.workflows.1.mutator.type == "Mutator"
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/molecule.yml
new file mode 100644
index 000000000..ee45d467f
--- /dev/null
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_pipeline/molecule.yml
@@ -0,0 +1,31 @@
+platforms:
+ - name: v6.10.0
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.10.0
+ pre_build_image: true
+ pull: true
+ override_command: false
+ - name: v6.9.0
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.9.0
+ pre_build_image: true
+ pull: true
+ override_command: false
+ - name: v6.8.2
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.8.2
+ pre_build_image: true
+ pull: true
+ override_command: false
+ - name: v6.7.5
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.7.5
+ pre_build_image: true
+ pull: true
+ override_command: false
+ - name: v6.6.2
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.6.2
+ pre_build_image: true
+ pull: true
+ override_command: false
+ - name: v6.5.5
+ image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.5.5
+ pre_build_image: true
+ pull: true
+ override_command: false
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role/converge.yml
index b1871e70e..cc720b6f2 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a role with missing required parameters
role:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role_binding/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role_binding/converge.yml
index 25f796769..4d426b9f1 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role_binding/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_role_binding/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create a role binding with missing required parameters
role_binding:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_env/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_env/converge.yml
index db34cca9b..ba89b602d 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_env/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_env/converge.yml
@@ -1,7 +1,7 @@
---
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all secrets providers and verify the presence of the
default env provider
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_vault/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_vault/converge.yml
index a5971afc4..653851f2d 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_vault/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_secrets_provider_vault/converge.yml
@@ -1,7 +1,7 @@
---
- name: Pre-converge step - ensure presence of valid PEM files for TLS configuration
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
# As part of configuring TLS for the vault secrets provider, we need
# to specify paths to CA cert and client cert/key files.
@@ -19,7 +19,7 @@
- name: Converge
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Fetch all secrets providers and verify the presence of the
default env provider
@@ -167,7 +167,7 @@
- result.objects.0.client.tls.ca_cert == '/tmp/ca.crt'
- name: Idempotence check for vault provider modification
- sensu.sensu_go.secrets_provider_vault: *update-provider
+ sensu.sensu_go.secrets_provider_vault: *update-provider
register: result
- ansible.builtin.assert:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_silence/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_silence/converge.yml
index 20496d0e8..77013636d 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_silence/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_silence/converge.yml
@@ -3,13 +3,13 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Create silence without parameters
silence:
auth:
url: http://localhost:8080
- ignore_errors: True
+ ignore_errors: true
register: result
- assert:
@@ -75,7 +75,7 @@
# expiring and getting dropped on the floor by the backend.
begin: 1893452400
expire: 120
- expire_on_resolve: True
+ expire_on_resolve: true
reason: updating mail server
register: result
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_socket_handler/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_socket_handler/converge.yml
index 8dcb5fc11..bfaeef718 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_socket_handler/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_socket_handler/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: true
tasks:
- name: Create socket handler with missing required parameters
socket_handler:
@@ -150,4 +150,4 @@
- assert:
that:
- result.objects | length == 1
- - result.objects.0.metadata.name == 'minimal_handler' \ No newline at end of file
+ - result.objects.0.metadata.name == 'minimal_handler'
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_tessen/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_tessen/converge.yml
index a06da3054..db6a54c5f 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_tessen/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_tessen/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
tasks:
- name: Call tessen with missing required parameters
tessen:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_user/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_user/converge.yml
index 7312779e6..2f209f092 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_user/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/module_user/converge.yml
@@ -3,7 +3,7 @@
collections:
- sensu.sensu_go
hosts: all
- gather_facts: no
+ gather_facts: false
environment:
SENSU_URL: http://localhost:8080
@@ -42,7 +42,7 @@
- name: Add disabled user to some groups
user:
name: awesome_username
- groups: [ a, b, c ]
+ groups: [a, b, c]
state: disabled
register: result
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_default/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_default/molecule.yml
index 505b22632..a067e8414 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_default/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_default/molecule.yml
@@ -13,7 +13,7 @@ platforms:
image: quay.io/xlab-steampunk/sensu-go-tests-centos:7
pre_build_image: true
pull: true
- groups: [ agents ]
+ groups: [agents]
override_command: false
privileged: true
volumes:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/converge.yml
index 7e0e1ccfa..0653dc711 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/converge.yml
@@ -1,7 +1,7 @@
---
- name: Pre-converge secure backend config step
hosts: backends
- gather_facts: no
+ gather_facts: false
tasks:
- name: Set dummy backend PKI variables
set_fact:
@@ -49,7 +49,7 @@
- name: Default configuration
hosts: agents
- gather_facts: no
+ gather_facts: false
roles:
- sensu.sensu_go.agent
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/molecule.yml
index 430054e8b..774cf3111 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_agent_secured/molecule.yml
@@ -4,7 +4,7 @@ platforms:
image: quay.io/xlab-steampunk/sensu-go-tests-centos:7
pre_build_image: true
pull: true
- groups: [ agents ]
+ groups: [agents]
override_command: false
privileged: true
volumes:
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_config/converge.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_config/converge.yml
index 056998447..e4af93a02 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_config/converge.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_config/converge.yml
@@ -9,7 +9,7 @@
tasks_from: configure
vars:
backend_config:
- debug: no
+ debug: false
log-level: debug
api-listen-address: "[::]:4430"
@@ -34,7 +34,7 @@
tasks_from: configure
vars:
backend_config:
- debug: yes
+ debug: true
log-level: debug
state-dir: /tmp/different/state
deregistration-handler: /tmp/handler.sh
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_default/verify.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_default/verify.yml
index c6d487eaa..e0a90881d 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_default/verify.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_backend_default/verify.yml
@@ -32,4 +32,4 @@
url: http://localhost:8080/auth
url_username: admin
url_password: P@ssw0rd!
- force_basic_auth: yes
+ force_basic_auth: true
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_build/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_build/molecule.yml
index 59e497b6b..a9cfcefe3 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_build/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_build/molecule.yml
@@ -1,7 +1,7 @@
---
platforms:
- name: ubuntu
- image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:16.04
+ image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04
pre_build_image: true
pull: true
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_version/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_version/molecule.yml
index 59e497b6b..a9cfcefe3 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_version/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_custom_version/molecule.yml
@@ -1,7 +1,7 @@
---
platforms:
- name: ubuntu
- image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:16.04
+ image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04
pre_build_image: true
pull: true
diff --git a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_default_deb/molecule.yml b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_default_deb/molecule.yml
index 1261bc9d0..5ae9068a1 100644
--- a/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_default_deb/molecule.yml
+++ b/ansible_collections/sensu/sensu_go/tests/integration/molecule/role_install_default_deb/molecule.yml
@@ -33,3 +33,8 @@ platforms:
image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04
pre_build_image: true
pull: true
+
+ - name: ubuntu-20.04
+ image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:20.04
+ pre_build_image: true
+ pull: true
diff --git a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_datastore.py b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_datastore.py
index 665b29ab8..b57d74a5b 100644
--- a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_datastore.py
+++ b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_datastore.py
@@ -208,7 +208,7 @@ class TestDatastore(ModuleTestCase):
type="PostgresConfig",
api_version="store/v1",
metadata=dict(name="test_datastore"),
- spec=dict(dsn="my-dsn"),
+ spec=dict(dsn="my-dsn", pool_size=0, max_idle_conns=2, batch_buffer=0, batch_size=1, enable_round_robin=False, strict=False),
)
assert check_mode is False
@@ -253,7 +253,7 @@ class TestDatastore(ModuleTestCase):
type="PostgresConfig",
api_version="store/v1",
metadata=dict(name="test_datastore"),
- spec=dict(dsn="my-dsn", pool_size=543),
+ spec=dict(dsn="my-dsn", pool_size=543, max_idle_conns=2, batch_buffer=0, batch_size=1, enable_round_robin=False, strict=False),
)
assert check_mode is False
@@ -267,3 +267,82 @@ class TestDatastore(ModuleTestCase):
with pytest.raises(AnsibleFailJson):
datastore.main()
+
+
+class TestDatastoreParams(ModuleTestCase):
+ @pytest.mark.parametrize(
+ # name ... Resource name
+ # state ... Prefered resource state (Present/Absent)
+ # dsn ... url or postgre connection string
+ # pool_size ... max number of connections
+ # max_conn_lifetime ... max time a connection can persist
+ # max_idle_conns ... max number of idle connections
+ # batch_workers ... number of GOroutines
+ # batch_buffer ... max requests to buffer in memory
+ # batch_size ... number of requests in each transaction
+ # enable_round_robin ... round robin (True/False)
+ # strict ... strict (True/False)
+ # expected_payload ... expected payload
+ ("name", "state", "dsn", "pool_size", "max_conn_lifetime", "max_idle_conns", "batch_workers",
+ "batch_buffer", "batch_size", "enable_round_robin", "strict", "expected_payload"),
+ [
+ # Present
+ ("my_resource", "present", "postgresql://user:secret@host:port/dbname", 2, 1, 1, 1, 1, 1,
+ False, True,
+ {'type': 'PostgresConfig', 'api_version': 'store/v1', 'metadata': {'name': 'my_resource'},
+ 'spec':
+ {
+ 'dsn': 'postgresql://user:secret@host:port/dbname', 'pool_size': 2, 'max_conn_lifetime': '1',
+ 'max_idle_conns': 1, 'batch_workers': 1, 'batch_buffer': 1, 'batch_size': 1,
+ 'enable_round_robin': False, 'strict': True}}),
+
+ ("another_resource", "present", "postgresql://user:secret@host:port/dbname", 0, 0, 0, 0, 0, 0,
+ False, False,
+ {'type': 'PostgresConfig', 'api_version': 'store/v1', 'metadata': {'name': 'another_resource'},
+ 'spec':
+ {
+ 'dsn': 'postgresql://user:secret@host:port/dbname', 'pool_size': 0, 'max_conn_lifetime': '0',
+ 'max_idle_conns': 0, 'batch_workers': 0, 'batch_buffer': 0, 'batch_size': 0,
+ 'enable_round_robin': False, 'strict': False}}),
+ # Absent
+ ("my_resource", "absent", "", None, None, None, None, None, None,
+ False, True,
+ {'type': 'PostgresConfig', 'api_version': 'store/v1', 'metadata': {'name': 'my_resource'},
+ 'spec':
+ {
+ 'dsn': '', 'enable_round_robin': False, 'strict': True}}),
+
+ ("my_resource", "absent", "postgresql://user:secret@host:port/dbname", 2, 1, 1, 1, 2, 3,
+ False, True,
+ {'type': 'PostgresConfig', 'api_version': 'store/v1', 'metadata': {'name': 'my_resource'},
+ 'spec':
+ {
+ 'dsn': 'postgresql://user:secret@host:port/dbname', 'pool_size': 2, 'max_conn_lifetime': '1',
+ 'max_idle_conns': 1, 'batch_workers': 1, 'batch_buffer': 2, 'batch_size': 3,
+ 'enable_round_robin': False, 'strict': True}}),
+ ],
+ )
+ def test_parameters_datastore(self, mocker, name, state, dsn, pool_size, max_conn_lifetime, max_idle_conns, batch_workers,
+ batch_buffer, batch_size, enable_round_robin, strict, expected_payload):
+ sync_mock = mocker.patch.object(datastore, "sync")
+ sync_mock.return_value = True, {}
+ set_module_args(
+ name=name,
+ dsn=dsn,
+ state=state,
+ pool_size=pool_size,
+ max_conn_lifetime=max_conn_lifetime,
+ max_idle_conns=max_idle_conns,
+ batch_workers=batch_workers,
+ batch_buffer=batch_buffer,
+ batch_size=batch_size,
+ enable_round_robin=enable_round_robin,
+ strict=strict,
+ )
+ with pytest.raises(AnsibleExitJson):
+ datastore.main()
+ state_test, _client_test, list_path_test, resource_path_test, payload_test, check_mode_test = (
+ sync_mock.call_args[0]
+ )
+ assert state_test == state
+ assert payload_test == expected_payload
diff --git a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline.py b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline.py
new file mode 100644
index 000000000..8edec0355
--- /dev/null
+++ b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline.py
@@ -0,0 +1,179 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import sys
+
+import pytest
+
+from ansible_collections.sensu.sensu_go.plugins.module_utils import (
+ errors, utils,
+)
+from ansible_collections.sensu.sensu_go.plugins.modules import pipeline
+
+from .common.utils import (
+ AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args,
+)
+
+pytestmark = pytest.mark.skipif(
+ sys.version_info < (2, 7), reason="requires python2.7 or higher"
+)
+
+
+class TestDoDiffer:
+ @pytest.mark.parametrize("current,desired", [
+ ( # No diff in params, no secrets
+ dict(name="demo"),
+ dict(name="demo"),
+ ),
+ ])
+ def test_no_difference(self, current, desired):
+ assert pipeline.do_differ(current, desired) is False
+
+ @pytest.mark.parametrize("current,desired", [
+ ( # Diff in params, no diff in secrets
+ dict(name="demo", secrets=[dict(name="a", secret="1")]),
+ dict(name="prod", secrets=[dict(name="a", secret="1")]),
+ ),
+ ( # No diff in params, missing and set secrets
+ dict(name="demo", secrets=[dict(name="a", secret="1")]),
+ dict(name="demo", secrets=[dict(name="b", secret="2")]),
+ ),
+ ( # Diff in params, missing and set secrets
+ dict(name="demo", secrets=[dict(name="a", secret="1")]),
+ dict(name="prod", secrets=[dict(name="b", secret="2")]),
+ ),
+ ])
+ def test_difference(self, current, desired):
+ assert pipeline.do_differ(current, desired) is True
+
+
+class TestHandle(ModuleTestCase):
+ def test_handle_api_version_and_types(self, mocker):
+ module = mocker.patch('ansible.module_utils.basic.AnsibleModule')
+ module.params = dict(workflows=[dict(handler=dict(name="test_handler", type="handler"))])
+ payload = dict(workflows=[dict(handler=dict(name="test_handler", type="handler"))])
+ pipeline.handle_api_version_and_types(module, payload)
+ expected = dict(
+ workflows=[dict(
+ handler=dict(name="test_handler", type="Handler", api_version="core/v2")
+ )]
+ )
+ assert module.params != payload
+ assert payload == expected
+
+ @pytest.mark.parametrize("payload_handler, expected", [
+ (
+ dict(name="test_handler", type="handler"),
+ dict(name="test_handler", type="Handler", api_version="core/v2"),
+ ),
+ (
+ dict(name="test_handler", type="tcp_stream_handler"),
+ dict(name="test_handler", type="TCPStreamHandler", api_version="pipeline/v1"),
+ ),
+ (
+ dict(name="test_handler", type="sumo_logic_metrics_handler"),
+ dict(name="test_handler", type="SumoLogicMetricsHandler", api_version="pipeline/v1"),
+ ),
+ ])
+ def test_handle_handler_api_and_type(self, payload_handler, expected):
+ pipeline.handle_handler_api_and_type(payload_handler)
+ assert payload_handler == expected
+
+ @pytest.mark.parametrize("payload_mutator, expected", [
+ (
+ dict(name="test_mutator", type="mutator"),
+ dict(name="test_mutator", type="Mutator", api_version="core/v2"),
+ ),
+ ])
+ def test_handle_mutator_api_and_type(self, payload_mutator, expected):
+ pipeline.handle_mutator_api_and_type(payload_mutator)
+ assert payload_mutator == expected
+
+ @pytest.mark.parametrize("workflow, payload_filters, expected", [
+ (
+ dict(filters=[dict(name="test_filter", type="event_filter")]),
+ [dict(name="test_filter", type="event_filter")],
+ [dict(name="test_filter", type="EventFilter", api_version="core/v2")],
+ ),
+ (
+ dict(filters=[dict(name="test_filter", type="event_filter"),
+ dict(name="test_filter_2", type="event_filter")]),
+ [dict(name="test_filter", type="event_filter"), dict(name="test_filter_2", type="event_filter")],
+ [dict(name="test_filter", type="EventFilter", api_version="core/v2"),
+ dict(name="test_filter_2", type="EventFilter", api_version="core/v2")],
+ ),
+ ])
+ def test_handle_filter_api_and_type(self, workflow, payload_filters, expected):
+ pipeline.handle_filter_api_and_type(payload_filters, workflow)
+ assert payload_filters == expected
+
+
+class TestPipeline(ModuleTestCase):
+ def test_minimal_pipeline_parameters(self, mocker):
+ sync_mock = mocker.patch.object(utils, 'sync')
+ sync_mock.return_value = True, {}
+ set_module_args(
+ name='test_pipeline',
+ workflows=[dict(name='test_wf', handler=dict(name='test_handler', type='handler'))]
+ )
+
+ with pytest.raises(AnsibleExitJson):
+ pipeline.main()
+
+ state, _client, path, payload, check_mode, _d = sync_mock.call_args[0]
+ assert state == 'present'
+ assert path == '/api/core/v2/namespaces/default/pipelines/test_pipeline'
+ assert payload == dict(
+ workflows=[dict(
+ name='test_wf', handler=dict(
+ name='test_handler', type='Handler', api_version='core/v2'))],
+ metadata=dict(
+ name='test_pipeline',
+ namespace='default',
+ ),
+ )
+ assert check_mode is False
+
+ def test_all_pipeline_parameters(self, mocker):
+ sync_mock = mocker.patch.object(utils, 'sync')
+ sync_mock.return_value = True, {}
+ set_module_args(
+ name='test_pipeline',
+ namespace='my',
+ state='absent',
+ workflows=[dict(name='test_wf', handler=dict(name='test_handler', type='handler'),
+ filters=[dict(name='test_filter', type='event_filter')],
+ mutator=dict(name='test_mutator', type='mutator')
+ )
+ ],
+ labels={'region': 'us-west-1'}
+ )
+
+ with pytest.raises(AnsibleExitJson):
+ pipeline.main()
+
+ state, _client, path, payload, check_mode, _d = sync_mock.call_args[0]
+ assert state == 'absent'
+ assert path == '/api/core/v2/namespaces/my/pipelines/test_pipeline'
+ assert payload == dict(
+ metadata=dict(
+ name='test_pipeline',
+ namespace='my',
+ labels={'region': 'us-west-1'},
+ ),
+ workflows=[dict(name='test_wf', handler=dict(name='test_handler', type='handler'),
+ filters=[dict(name='test_filter', type='event_filter')],
+ mutator=dict(name='test_mutator', type='mutator')
+ )]
+ )
+ assert check_mode is False
+
+ def test_failure(self, mocker):
+ sync_mock = mocker.patch.object(utils, 'sync')
+ sync_mock.side_effect = errors.Error('Bad error')
+ set_module_args(
+ name='test_pipeline',
+ )
+
+ with pytest.raises(AnsibleFailJson):
+ pipeline.main()
diff --git a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline_info.py b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline_info.py
new file mode 100644
index 000000000..c99f7205d
--- /dev/null
+++ b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_pipeline_info.py
@@ -0,0 +1,63 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import sys
+
+import pytest
+
+from ansible_collections.sensu.sensu_go.plugins.module_utils import (
+ errors, utils,
+)
+from ansible_collections.sensu.sensu_go.plugins.modules import pipeline_info
+
+from .common.utils import (
+ AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args,
+)
+
+pytestmark = pytest.mark.skipif(
+ sys.version_info < (2, 7), reason="requires python2.7 or higher"
+)
+
+
+class TestPipelineInfo(ModuleTestCase):
+ def test_get_all_pipelines(self, mocker):
+ get_mock = mocker.patch.object(utils, "get")
+ get_mock.return_value = [1, 2, 3]
+ set_module_args(namespace="my")
+
+ with pytest.raises(AnsibleExitJson) as context:
+ pipeline_info.main()
+
+ _client, path = get_mock.call_args[0]
+ assert path == "/api/core/v2/namespaces/my/pipelines"
+ assert context.value.args[0]["objects"] == [1, 2, 3]
+
+ def test_get_single_pipeline(self, mocker):
+ get_mock = mocker.patch.object(utils, "get")
+ get_mock.return_value = 4
+ set_module_args(name="sample-pipeline")
+
+ with pytest.raises(AnsibleExitJson) as context:
+ pipeline_info.main()
+
+ _client, path = get_mock.call_args[0]
+ assert path == "/api/core/v2/namespaces/default/pipelines/sample-pipeline"
+ assert context.value.args[0]["objects"] == [4]
+
+ def test_missing_single_mutator(self, mocker):
+ get_mock = mocker.patch.object(utils, "get")
+ get_mock.return_value = None
+ set_module_args(name="sample-pipeline")
+
+ with pytest.raises(AnsibleExitJson) as context:
+ pipeline_info.main()
+
+ assert context.value.args[0]["objects"] == []
+
+ def test_failure(self, mocker):
+ get_mock = mocker.patch.object(utils, "get")
+ get_mock.side_effect = errors.Error("Bad error")
+ set_module_args(name="sample-pipeline")
+
+ with pytest.raises(AnsibleFailJson):
+ pipeline_info.main()
diff --git a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_user.py b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_user.py
index 52e4a7698..cbe9a3655 100644
--- a/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_user.py
+++ b/ansible_collections/sensu/sensu_go/tests/unit/plugins/modules/test_user.py
@@ -79,6 +79,39 @@ class TestUpdatePassword:
client.validate_auth_data.assert_called_once_with('user', 'pass')
client.put.assert_not_called()
+ @pytest.mark.parametrize(
+ # bcrypt_present ... is bcrypt library present (True/False).
+ # expected_exception ... is missing requirements exception expected.
+ # expected_result ... expected update_password return.
+ (
+ "bcrypt_present",
+ "expected_exception",
+ "expected_result",
+ ),
+ [
+ # bcrypt present
+ (True, False, True),
+ # bcrypt not present
+ (False, True, None),
+ ],
+ )
+ def test_missing_bcrypt_library(self, mocker, bcrypt_present, expected_exception, expected_result):
+ # Mock HAS_BCRYPT global variable
+ mocker.patch("ansible_collections.sensu.sensu_go.plugins.modules.user.HAS_BCRYPT", bcrypt_present)
+
+ # Mock client
+ client = mocker.Mock()
+ client.validate_auth_data.return_value = False
+ client.version = version.StrictVersion("5.21.1")
+ client.put.return_value = http.Response(201, '')
+
+ if expected_exception:
+ with pytest.raises(errors.RequirementsError):
+ user.update_password(client, "", "", "", False)
+ else:
+ result = user.update_password(client, "", "", "", False)
+ assert result is expected_result
+
class TestUpdatePasswordHash:
@pytest.mark.parametrize('check', [False, True])
@@ -506,14 +539,24 @@ class TestUser(ModuleTestCase):
user.main()
def test_failure_on_missing_bcrypt_5_21_0_or_newer(self, mocker):
+ # Check that there is no missing library exception during user creation
mocker.patch.object(arguments, 'get_sensu_client').return_value = (
mocker.MagicMock(version='5.22.3')
)
+ sync_mock = mocker.patch.object(user, 'sync')
+ sync_mock.return_value = True, {}
+
+ mocker.patch.object(utils, 'get').return_value = None
mocker.patch.object(user, 'HAS_BCRYPT', False)
+
set_module_args(
name='test_user',
password='password'
)
- with pytest.raises(AnsibleFailJson, match='bcrypt'):
+ with pytest.raises(AnsibleExitJson):
user.main()
+ result, _client, path, payload, check_mode = sync_mock.call_args[0]
+
+ assert result is None
+ assert payload == dict(password="password", username="test_user", disabled=False)