Remove rabbitmq content (#13)

This content has been moved to:
https://github.com/ansible-collections/rabbitmq
This commit is contained in:
Jesse Pretorius 2020-03-17 09:01:39 +00:00 committed by GitHub
parent 1f06a02043
commit 5d47ab7096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 0 additions and 3854 deletions

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

View file

@ -1,2 +0,0 @@
dependencies:
- setup_rabbitmq

View file

@ -1,3 +0,0 @@
---
- import_tasks: tests.yml
when: ansible_distribution == 'Ubuntu'

View file

@ -1,132 +0,0 @@
---
- name: Add test requisites
block:
- name: Add exchange
rabbitmq_exchange:
name: "{{ item }}"
type: direct
with_items:
- exchange-foo
- exchange-bar
- name: Add queue
rabbitmq_queue:
name: queue-foo
- name: Test add binding in check mode
block:
- name: Add binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
check_mode: true
register: add_binding
- name: Check that binding succeeds with a change
assert:
that:
- add_binding.changed == true
- name: Test add binding
block:
- name: Add binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
register: add_binding
- name: Check that binding succeeds with a change
assert:
that:
- add_binding.changed == true
- name: Test add binding idempotence
block:
- name: Add binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
register: add_binding
- name: Check that binding succeeds without a change
assert:
that:
- add_binding.changed == false
- name: Test remove binding in check mode
block:
- name: Remove binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
state: absent
check_mode: true
register: remove_binding
- name: Check that binding succeeds with a change
assert:
that:
- remove_binding.changed == true
- name: Test remove binding
block:
- name: Remove binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
state: absent
register: remove_binding
- name: Check that binding succeeds with a change
assert:
that:
- remove_binding.changed == true
- name: Test remove binding idempotence
block:
- name: Remove binding
rabbitmq_binding:
source: exchange-foo
destination: queue-foo
type: queue
state: absent
register: remove_binding
- name: Check that binding succeeds with a change
assert:
that:
- remove_binding.changed == false
- name: Test add exchange to exchange binding
block:
- name: Add binding
rabbitmq_binding:
source: exchange-foo
destination: exchange-bar
type: exchange
register: add_binding
- name: Check that binding succeeds with a change
assert:
that:
- add_binding.changed == true
- name: Test remove exchange to exchange binding
block:
- name: Remove binding
rabbitmq_binding:
source: exchange-foo
destination: exchange-bar
type: exchange
state: absent
register: remove_binding
- name: Check that binding succeeds with a change
assert:
that:
- remove_binding.changed == true

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

View file

@ -1,2 +0,0 @@
dependencies:
- setup_rabbitmq

View file

@ -1,2 +0,0 @@
- import_tasks: tests.yml
when: ansible_distribution == 'Ubuntu'

View file

@ -1,71 +0,0 @@
- block:
- set_fact:
plugin_name: rabbitmq_top
- name: Enable plugin
rabbitmq_plugin:
name: "{{ plugin_name }}"
state: enabled
new_only: True
register: result
- name: Get rabbitmq-plugins output
shell: "rabbitmq-plugins list | grep {{ plugin_name }}"
register: cli_result
- name: Check that the plugin is enabled
assert:
that:
- result is changed
- result is success
- '"{{ plugin_name }}" in result.enabled'
- result.disabled == []
- '"[E" in cli_result.stdout'
- name: Enable plugin (idempotency)
rabbitmq_plugin:
name: "{{ plugin_name }}"
state: enabled
new_only: True
register: result
- name: Check idempotency
assert:
that:
- result is not changed
- name: Disable plugin
rabbitmq_plugin:
name: "{{ plugin_name }}"
state: disabled
register: result
- name: Get rabbitmq-plugins output
shell: "rabbitmq-plugins list | grep {{ plugin_name }}"
register: cli_result
- name: Check that the plugin is disabled
assert:
that:
- result is changed
- result is success
- result.enabled == []
- '"{{ plugin_name }}" in result.disabled'
- '"[E" not in cli_result.stdout'
- name: Disable plugin (idempotency)
rabbitmq_plugin:
name: "{{ plugin_name }}"
state: disabled
register: result
- name: Check idempotency
assert:
that:
- result is not changed
always:
- name: Disable plugin
rabbitmq_plugin:
name: "{{ plugin_name }}"
state: disabled

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 B

View file

@ -1,3 +0,0 @@
dependencies:
- setup_rabbitmq
- setup_remote_tmp_dir

View file

@ -1,5 +0,0 @@
# Rabbitmq lookup
- include: ubuntu.yml
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_release != 'trusty'

View file

@ -1,171 +0,0 @@
- name: Install requests and pika
pip:
name: requests,pika<1.0.0
state: present
- name: RabbitMQ basic publish test
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: 'publish_test'
body: "Hello world from ansible module rabbitmq_publish"
content_type: "text/plain"
register: rabbit_basic_output1
- assert:
that:
- "rabbit_basic_output1 is not failed"
- "'publish_test' in rabbit_basic_output1.result.msg"
- "'publish_test' in rabbit_basic_output1.result.queue"
- "'text/plain' in rabbit_basic_output1.result.content_type"
# Testing random queue
- name: Publish to random queue
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
body: "RANDOM QUEUE POST"
content_type: "text/plain"
register: rabbit_random_queue_output
- assert:
that:
- "rabbit_random_queue_output is not failed"
- "'amq.gen' in rabbit_random_queue_output.result.msg"
- "'amq.gen' in rabbit_random_queue_output.result.queue"
- "'text/plain' in rabbit_random_queue_output.result.content_type"
- name: Copy binary to remote
copy:
src: "{{ role_path }}/files/image.gif"
dest: "{{ remote_tmp_dir }}/image.gif"
- name: Publish binary to a queue
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: publish_test
src: "{{ remote_tmp_dir }}/image.gif"
register: rabbitmq_publish_file
- assert:
that:
- "rabbitmq_publish_file is not failed"
- "'publish_test' in rabbitmq_publish_file.result.queue"
- "'image/gif' in rabbitmq_publish_file.result.content_type"
- name: Raise error for src and body defined
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: 'publish_test'
src: "{{ remote_tmp_dir }}/image.gif"
body: blah
register: rabbit_basic_fail_output1
ignore_errors: yes
- assert:
that:
- "rabbit_basic_fail_output1 is failed"
- "'parameters are mutually exclusive' in rabbit_basic_fail_output1.msg"
- name: Publish a file that does not exist
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: 'publish_test'
src: 'aaaaaaajax-loader.gif'
register: file_missing_fail
ignore_errors: yes
- assert:
that:
- "file_missing_fail is failed"
- "'Unable to open file' in file_missing_fail.msg"
- name: Publish with proto/host/port/user/pass
rabbitmq_publish:
proto: amqp
host: localhost
port: 5672
username: guest
password: guest
vhost: '%2F'
queue: publish_test
body: Testing with proto/host/port/username/password/vhost
register: host_port_output
- assert:
that:
- "host_port_output is not failed"
- name: Publish with host/port/user but missing proto
rabbitmq_publish:
host: localhost
port: 5672
username: guest
password: guest
vhost: '%2F'
queue: publish_test
body: Testing with proto/host/port/username/password/vhost
ignore_errors: yes
register: host_port_missing_proto_output
- assert:
that:
- "host_port_missing_proto_output is failed"
- "'Connection parameters must be passed via' in host_port_missing_proto_output.msg"
- name: Publish with proto/host/port/user and url
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
proto: amqp
host: localhost
port: 5672
username: guest
password: guest
vhost: '%2F'
queue: publish_test
body: Testing with proto/host/port/username/password/vhost
ignore_errors: yes
register: host_and_url_output
- assert:
that:
- "host_and_url_output is failed"
- "'cannot be specified at the same time' in host_and_url_output.msg"
- name: Publish headers to queue
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: 'publish_test'
body: blah
headers:
myHeader: Value1
secondHeader: Value2
register: test_headers1
ignore_errors: yes
- name: Publish headers with file
rabbitmq_publish:
url: "amqp://guest:guest@localhost:5672/%2F"
queue: 'publish_test'
src: "{{ remote_tmp_dir }}/image.gif"
headers:
myHeader: Value1
secondHeader: Value2
register: test_headers2
ignore_errors: yes
- name: Collect all messages off the publish queue
set_fact:
messages: "{{ lookup('rabbitmq', url='amqp://guest:guest@localhost:5672/%2F', queue='publish_test') }}"
- name: Check contents of published messages
assert:
that:
- messages|length == 5
- "'Hello world from ansible module rabbitmq_publish' in messages[0]['msg']"
- "'text/plain' in messages[0]['content_type']"
- "'image/gif' in messages[1]['content_type']"
- "'image.gif' in messages[1]['headers']['filename']"
- "'Testing with proto/host/port/username/password/vhost' in messages[2]['msg']"
# - messages[3]['headers']['myHeader'] is defined
# - messages[4]['headers']['filename'] is defined
# - messages[4]['headers']['secondHeader'] is defined

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

View file

@ -1,2 +0,0 @@
dependencies:
- setup_rabbitmq

View file

@ -1,10 +0,0 @@
---
- when: ansible_distribution == 'Ubuntu'
block:
- import_tasks: tests.yml
- import_tasks: tests.yml
environment:
RABBITMQ_NODENAME: test

View file

@ -1,137 +0,0 @@
---
- name: Test add user in check mode
block:
- name: Add user
rabbitmq_user: user=joe password=changeme
check_mode: true
register: add_user
- name: Check that user adding succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test add user
block:
- name: Add user
rabbitmq_user: user=joe password=changeme
register: add_user
- name: Check that user adding succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test add user idempotence
block:
- name: Add user
rabbitmq_user: user=joe password=changeme
register: add_user
- name: Check that user adding succeeds without a change
assert:
that:
- add_user.changed == false
- name: Test change user permissions in check mode
block:
- name: Add user with permissions
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
check_mode: true
register: add_user
- name: Check that changing permissions succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test change user permissions
block:
- name: Add user with permissions
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
register: add_user
- name: Check that changing permissions succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test change user permissions idempotence
block:
- name: Add user with permissions
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
register: add_user
- name: Check that changing permissions succeeds without a change
assert:
that:
- add_user.changed == false
- name: Test add user tags in check mode
block:
- name: Add user with tags
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=management,administrator
check_mode: true
register: add_user
- name: Check that adding tags succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test add user tags
block:
- name: Add user with tags
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=management,administrator
register: add_user
- name: Check that adding tags succeeds with a change
assert:
that:
- add_user.changed == true
- name: Test add user tags idempotence
block:
- name: Add user with tags
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=administrator,management
register: add_user
- name: Check that adding tags succeeds without a change
assert:
that:
- add_user.changed == false
- name: Test remove user in check mode
block:
- name: Remove user
rabbitmq_user: user=joe state=absent
check_mode: true
register: remove_user
- name: Check that user removing succeeds with a change
assert:
that:
- remove_user.changed == true
- name: Test remove user
block:
- name: Remove user
rabbitmq_user: user=joe state=absent
register: remove_user
- name: Check that user removing succeeds with a change
assert:
that:
- remove_user.changed == true
- name: Test remove user idempotence
block:
- name: Remove user
rabbitmq_user: user=joe state=absent
register: remove_user
- name: Check that user removing succeeds without a change
assert:
that:
- remove_user.changed == false

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

View file

@ -1,2 +0,0 @@
dependencies:
- setup_rabbitmq

View file

@ -1,2 +0,0 @@
- import_tasks: tests.yml
when: ansible_distribution == 'Ubuntu'

View file

@ -1,121 +0,0 @@
- block:
- set_fact:
vhost_name: /test
- name: Add host
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: present
register: result
- name: Check that the host was created successfuly
shell: "rabbitmqctl list_vhosts name tracing | grep {{ vhost_name }}"
register: ctl_result
- name: Check that the host is added
assert:
that:
- result is changed
- result is success
- '"false" in ctl_result.stdout' # value for tracing, false is disabled
- name: Add host (idempotency)
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: present
register: result
- name: Check idempotency
assert:
that:
- result is not changed
- name: Enable tracing
rabbitmq_vhost:
name: "{{ vhost_name }}"
tracing: yes
register: result
- name: Get rabbitmqctl output
shell: "rabbitmqctl list_vhosts name tracing | grep {{ vhost_name }}"
register: ctl_result
- name: Check that tracing is enabled
assert:
that:
- result is changed
- result is success
- '"true" in ctl_result.stdout' # value for tracing, true is enabled
- name: Enable tracing (idempotency)
rabbitmq_vhost:
name: "{{ vhost_name }}"
tracing: yes
register: result
- name: Check idempotency
assert:
that:
- result is not changed
- name: Disable tracing
rabbitmq_vhost:
name: "{{ vhost_name }}"
tracing: no
register: result
- name: Get rabbitmqctl output
shell: "rabbitmqctl list_vhosts name tracing | grep {{ vhost_name }}"
register: ctl_result
- name: Check that tracing is disabled
assert:
that:
- result is changed
- result is success
- '"false" in ctl_result.stdout' # value for tracing, false is disabled
- name: Disable tracing (idempotency)
rabbitmq_vhost:
name: "{{ vhost_name }}"
tracing: no
register: result
- name: Check idempotency
assert:
that:
- result is not changed
- name: Remove host
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: absent
register: result
- name: Get rabbitmqctl output
shell: "rabbitmqctl list_vhosts name tracing | grep {{ vhost_name }}"
register: ctl_result
failed_when: ctl_result.rc == 0
- name: Check that the host is removed
assert:
that:
- result is changed
- result is success
- name: Remove host (idempotency)
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: absent
register: result
- name: Check idempotency
assert:
that:
- result is not changed
always:
- name: Remove host
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: absent

View file

@ -1,6 +0,0 @@
destructive
shippable/posix/group1
skip/aix
skip/osx
skip/freebsd
skip/rhel

View file

@ -1,2 +0,0 @@
dependencies:
- setup_rabbitmq

View file

@ -1,5 +0,0 @@
# Rabbitmq lookup
- include: ubuntu.yml
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_release != 'trusty'

View file

@ -1,163 +0,0 @@
---
- name: Test setting virtual host limits in check mode
block:
- name: Set virtual host limits in check mode
rabbitmq_vhost_limits:
vhost: /
max_connections: 64
max_queues: 256
state: present
check_mode: true
register: module_result
- name: Check that the module's result is correct
assert:
that:
- module_result is changed
- module_result is success
- name: Get a list of configured virtual host limits
shell: "rabbitmqctl list_vhost_limits"
register: shell_result
- name: Check that the check mode does not make any changes
assert:
that:
- shell_result is success
- "'\"max-connections\":64' not in shell_result.stdout"
- "'\"max-queues\":256' not in shell_result.stdout"
- name: Test setting virtual host limits
block:
- name: Set virtual host limits
rabbitmq_vhost_limits:
vhost: /
max_connections: 64
max_queues: 256
state: present
register: module_result
- name: Check that the module's result is correct
assert:
that:
- module_result is changed
- module_result is success
- name: Get a list of configured virtual host limits
shell: "rabbitmqctl list_vhost_limits"
register: shell_result
- name: Check that the virtual host limits are actually set
assert:
that:
- shell_result is success
- "'\"max-connections\":64' in shell_result.stdout"
- "'\"max-queues\":256' in shell_result.stdout"
- name: Test setting virtual host limits (idempotence)
block:
- name: Set virtual host limits (idempotence)
rabbitmq_vhost_limits:
vhost: /
max_connections: 64
max_queues: 256
state: present
register: module_result
- name: Check the idempotence
assert:
that:
- module_result is not changed
- module_result is success
- name: Test changing virtual host limits
block:
- name: Change virtual host limits
rabbitmq_vhost_limits:
vhost: /
max_connections: 32
state: present
register: module_result
- name: Check that the module's result is correct
assert:
that:
- module_result is changed
- module_result is success
- name: Get a list of configured virtual host limits
shell: "rabbitmqctl list_vhost_limits"
register: shell_result
- name: Check that the virtual host limits are actually set
assert:
that:
- shell_result is success
- "'\"max-connections\":32' in shell_result.stdout"
- "'\"max-queues\":-1' in shell_result.stdout"
- name: Test clearing virtual host limits in check mode
block:
- name: Clear virtual host limits in check mode
rabbitmq_vhost_limits:
vhost: /
state: absent
check_mode: true
register: module_result
- name: Check that the module's result is correct
assert:
that:
- module_result is changed
- module_result is success
- name: Get a list of configured virtual host limits
shell: "rabbitmqctl list_vhost_limits"
register: shell_result
- name: Check that the check mode does not make any changes
assert:
that:
- shell_result is success
- "'\"max-connections\":32' in shell_result.stdout"
- "'\"max-queues\":-1' in shell_result.stdout"
- name: Test clearing virtual host limits
block:
- name: Clear virtual host limits
rabbitmq_vhost_limits:
vhost: /
state: absent
register: module_result
- name: Check that the module's result is correct
assert:
that:
- module_result is changed
- module_result is success
- name: Get a list of configured virtual host limits
shell: "rabbitmqctl list_vhost_limits"
register: shell_result
- name: Check that the virtual host limits are actually cleared
assert:
that:
- shell_result is success
- "'\"max-connections\":' not in shell_result.stdout"
- "'\"max-queues\":' not in shell_result.stdout"
- name: Test clearing virtual host limits (idempotence)
block:
- name: Clear virtual host limits (idempotence)
rabbitmq_vhost_limits:
vhost: /
state: absent
register: module_result
- name: Check the idempotence
assert:
that:
- module_result is not changed
- module_result is success

View file

@ -1,8 +0,0 @@
listeners.ssl.default = 5671
ssl_options.cacertfile = /tls/ca_certificate.pem
ssl_options.certfile = /tls/server_certificate.pem
ssl_options.keyfile = /tls/server_key.pem
ssl_options.password = bunnies
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false

View file

@ -988,26 +988,6 @@ plugins/modules/identity/keycloak/keycloak_clienttemplate.py validate-modules:pa
plugins/modules/identity/onepassword_info.py validate-modules:parameter-list-no-elements
plugins/modules/identity/opendj/opendj_backendprop.py validate-modules:doc-missing-type
plugins/modules/identity/opendj/opendj_backendprop.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_binding.py validate-modules:doc-default-does-not-match-spec
plugins/modules/messaging/rabbitmq/rabbitmq_binding.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_exchange.py validate-modules:doc-choices-do-not-match-spec
plugins/modules/messaging/rabbitmq/rabbitmq_exchange.py validate-modules:doc-default-does-not-match-spec
plugins/modules/messaging/rabbitmq/rabbitmq_exchange.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_global_parameter.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_global_parameter.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_parameter.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_plugin.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_policy.py validate-modules:doc-default-does-not-match-spec
plugins/modules/messaging/rabbitmq/rabbitmq_policy.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_policy.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_queue.py validate-modules:doc-default-does-not-match-spec
plugins/modules/messaging/rabbitmq/rabbitmq_queue.py validate-modules:doc-default-incompatible-type
plugins/modules/messaging/rabbitmq/rabbitmq_queue.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_user.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_user.py validate-modules:parameter-list-no-elements
plugins/modules/messaging/rabbitmq/rabbitmq_user.py validate-modules:parameter-type-not-in-doc
plugins/modules/messaging/rabbitmq/rabbitmq_vhost.py validate-modules:doc-missing-type
plugins/modules/messaging/rabbitmq/rabbitmq_vhost_limits.py validate-modules:parameter-type-not-in-doc
plugins/modules/monitoring/airbrake_deployment.py validate-modules:doc-default-does-not-match-spec
plugins/modules/monitoring/airbrake_deployment.py validate-modules:doc-missing-type
plugins/modules/monitoring/bigpanda.py validate-modules:doc-default-does-not-match-spec
@ -2806,7 +2786,6 @@ plugins/modules/notification/pushover.py validate-modules:doc-choices-do-not-mat
plugins/modules/notification/pushover.py validate-modules:doc-default-does-not-match-spec
plugins/modules/notification/pushover.py validate-modules:doc-missing-type
plugins/modules/notification/pushover.py validate-modules:parameter-type-not-in-doc
plugins/modules/notification/rabbitmq_publish.py validate-modules:parameter-type-not-in-doc
plugins/modules/notification/rocketchat.py validate-modules:no-default-for-required-parameter
plugins/modules/notification/rocketchat.py validate-modules:parameter-list-no-elements
plugins/modules/notification/rocketchat.py validate-modules:parameter-type-not-in-doc
@ -3490,8 +3469,6 @@ plugins/doc_fragments/proxysql.py future-import-boilerplate
plugins/doc_fragments/proxysql.py metaclass-boilerplate
plugins/doc_fragments/purestorage.py future-import-boilerplate
plugins/doc_fragments/purestorage.py metaclass-boilerplate
plugins/doc_fragments/rabbitmq.py future-import-boilerplate
plugins/doc_fragments/rabbitmq.py metaclass-boilerplate
plugins/doc_fragments/rackspace.py future-import-boilerplate
plugins/doc_fragments/rackspace.py metaclass-boilerplate
plugins/doc_fragments/scaleway.py future-import-boilerplate
@ -3589,8 +3566,6 @@ tests/unit/modules/cloud/xenserver/FakeXenAPI.py future-import-boilerplate
tests/unit/modules/cloud/xenserver/FakeXenAPI.py metaclass-boilerplate
tests/unit/modules/conftest.py future-import-boilerplate
tests/unit/modules/conftest.py metaclass-boilerplate
tests/unit/modules/messaging/rabbitmq/test_rabbitmq_user.py future-import-boilerplate
tests/unit/modules/messaging/rabbitmq/test_rabbitmq_user.py metaclass-boilerplate
tests/unit/modules/monitoring/test_circonus_annotation.py future-import-boilerplate
tests/unit/modules/monitoring/test_circonus_annotation.py metaclass-boilerplate
tests/unit/modules/monitoring/test_icinga2_feature.py future-import-boilerplate

View file

@ -1,134 +0,0 @@
# -*- coding: utf-8 -*-
from ansible_collections.community.general.plugins.modules.messaging.rabbitmq import rabbitmq_user
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.tests.unit.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args
class TestRabbitMQUserModule(ModuleTestCase):
def setUp(self):
super(TestRabbitMQUserModule, self).setUp()
self.module = rabbitmq_user
def tearDown(self):
super(TestRabbitMQUserModule, self).tearDown()
def _assert(self, exc, attribute, expected_value, msg=""):
value = exc.message[attribute] if hasattr(exc, attribute) else exc.args[0][attribute]
assert value == expected_value, msg
def test_without_required_parameters(self):
"""Failure must occurs when all parameters are missing"""
with self.assertRaises(AnsibleFailJson):
set_module_args({})
self.module.main()
def test_permissions_with_same_vhost(self):
set_module_args({
'user': 'someuser',
'password': 'somepassword',
'state': 'present',
'permissions': [{'vhost': '/'}, {'vhost': '/'}],
})
with patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') as get_bin_path:
get_bin_path.return_value = '/rabbitmqctl'
try:
self.module.main()
except AnsibleFailJson as e:
self._assert(e, 'failed', True)
self._assert(e, 'msg',
"Error parsing permissions: You can't have two permission dicts for the same vhost")
@patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.get')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.check_password')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.has_tags_modifications')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.has_permissions_modifications')
def test_password_changes_only_when_needed(self, has_permissions_modifications, has_tags_modifications,
check_password, get, get_bin_path):
set_module_args({
'user': 'someuser',
'password': 'somepassword',
'state': 'present',
'update_password': 'always',
})
get.return_value = True
get_bin_path.return_value = '/rabbitmqctl'
check_password.return_value = True
has_tags_modifications.return_value = False
has_permissions_modifications.return_value = False
try:
self.module.main()
except AnsibleExitJson as e:
self._assert(e, 'changed', False)
self._assert(e, 'state', 'present')
@patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._exec')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._get_permissions')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.has_tags_modifications')
def test_same_permissions_not_changing(self, has_tags_modifications, _get_permissions, _exec, get_bin_path):
set_module_args({
'user': 'someuser',
'password': 'somepassword',
'state': 'present',
'permissions': [{'vhost': '/', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}],
})
_get_permissions.return_value = [{'vhost': '/', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}]
_exec.return_value = ['someuser\t[]']
get_bin_path.return_value = '/rabbitmqctl'
has_tags_modifications.return_value = False
try:
self.module.main()
except AnsibleExitJson as e:
self._assert(e, 'changed', False)
self._assert(e, 'state', 'present')
@patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._exec')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._get_permissions')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.set_permissions')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.has_tags_modifications')
def test_permissions_are_fixed(self, has_tags_modifications, set_permissions, _get_permissions, _exec, get_bin_path):
set_module_args({
'user': 'someuser',
'password': 'somepassword',
'state': 'present',
'permissions': [{'vhost': '/', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}],
})
set_permissions.return_value = None
_get_permissions.return_value = []
_exec.return_value = ['someuser\t[]']
get_bin_path.return_value = '/rabbitmqctl'
has_tags_modifications.return_value = False
try:
self.module.main()
except AnsibleExitJson as e:
self._assert(e, 'changed', True)
self._assert(e, 'state', 'present')
assert set_permissions.call_count == 1
@patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._exec')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser._get_permissions')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.set_permissions')
@patch('ansible_collections.community.general.plugins.modules.messaging.rabbitmq.rabbitmq_user.RabbitMqUser.has_tags_modifications')
def test_permissions_are_fixed_with_different_host(self, has_tags_modifications, set_permissions, _get_permissions,
_exec, get_bin_path):
set_module_args({
'user': 'someuser',
'password': 'somepassword',
'state': 'present',
'permissions': [{'vhost': '/', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}],
})
set_permissions.return_value = None
_get_permissions.return_value = [{'vhost': 'monitoring', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}]
_exec.return_value = ['someuser\t[]']
get_bin_path.return_value = '/rabbitmqctl'
has_tags_modifications.return_value = False
try:
self.module.main()
except AnsibleExitJson as e:
self._assert(e, 'changed', True)
self._assert(e, 'state', 'present')
assert set_permissions.call_count == 1