summaryrefslogtreecommitdiffstats
path: root/ansible_collections/splunk/es/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/splunk/es/tests')
-rw-r--r--ansible_collections/splunk/es/tests/config.yml3
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/adaptive_response_notable_event/tasks/main.yml40
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/correlation_search_info/tasks/main.yml52
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/data_input_monitor/tasks/main.yml38
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/data_input_network/tasks/main.yml28
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/defaults/main.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/cli.yaml17
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/main.yaml4
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/redirection.yaml8
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tests/_populate_dim_config.yaml74
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/vars/main.yaml21
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_populate_config.yaml4
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_remove_config.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/merged.yaml5
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/replaced.yaml8
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/rtt.yaml4
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/defaults/main.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/cli.yaml17
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/main.yaml4
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/redirection.yaml8
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_populate_dim_config.yaml12
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_remove_dim_config.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/deleted.yaml5
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/merged.yaml16
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/replaced.yaml11
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/rtt.yaml11
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/vars/main.yaml47
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/defaults/main.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/cli.yaml17
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/main.yaml4
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/redirection.yaml8
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_populate_din_config.yaml12
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_remove_din_config.yaml2
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/merged.yaml10
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/replaced.yaml10
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/rtt.yaml20
-rw-r--r--ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/vars/main.yaml36
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.12.txt1
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.13.txt0
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.14.txt0
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.15.txt0
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.16.txt0
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.17.txt0
-rw-r--r--ansible_collections/splunk/es/tests/sanity/ignore-2.9.txt2
-rw-r--r--ansible_collections/splunk/es/tests/unit/compat/builtins.py34
-rw-r--r--ansible_collections/splunk/es/tests/unit/compat/mock.py4
-rw-r--r--ansible_collections/splunk/es/tests/unit/compat/unittest.py2
-rw-r--r--ansible_collections/splunk/es/tests/unit/mock/loader.py5
-rw-r--r--ansible_collections/splunk/es/tests/unit/mock/path.py9
-rw-r--r--ansible_collections/splunk/es/tests/unit/mock/procenv.py9
-rw-r--r--ansible_collections/splunk/es/tests/unit/mock/vault_helper.py6
-rw-r--r--ansible_collections/splunk/es/tests/unit/mock/yaml_helper.py38
-rw-r--r--ansible_collections/splunk/es/tests/unit/modules/conftest.py18
-rw-r--r--ansible_collections/splunk/es/tests/unit/modules/utils.py10
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/action/test_es_adaptive_response_notable_events.py155
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/action/test_es_correlation_searches.py75
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_monitors.py100
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_network.py198
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/modules/conftest.py18
-rw-r--r--ansible_collections/splunk/es/tests/unit/plugins/modules/utils.py10
60 files changed, 635 insertions, 625 deletions
diff --git a/ansible_collections/splunk/es/tests/config.yml b/ansible_collections/splunk/es/tests/config.yml
new file mode 100644
index 000000000..41f529264
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/config.yml
@@ -0,0 +1,3 @@
+---
+modules:
+ python_requires: ">=3.6"
diff --git a/ansible_collections/splunk/es/tests/integration/targets/adaptive_response_notable_event/tasks/main.yml b/ansible_collections/splunk/es/tests/integration/targets/adaptive_response_notable_event/tasks/main.yml
index d111fea78..12a6a008d 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/adaptive_response_notable_event/tasks/main.yml
+++ b/ansible_collections/splunk/es/tests/integration/targets/adaptive_response_notable_event/tasks/main.yml
@@ -1,24 +1,24 @@
---
-- name: remove previous correlation_search
+- name: Remove previous correlation_search
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "absent"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: absent
-- name: create correlation_search
+- name: Create correlation_search
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "present"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: present
- name: Test splunk.es.adaptive_response_notable_event
adaptive_response_notable_event:
- name: "Fake notable event from playbook"
- correlation_search_name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake notable event from playbook, description edition."
- state: "present"
+ name: Fake notable event from playbook
+ correlation_search_name: Test Fake Coorelation Search From Playbook
+ description: Test Fake notable event from playbook, description edition.
+ state: present
next_steps:
- ping
- nslookup
@@ -29,17 +29,17 @@
register: adaptive_response_notable_event_out
- name: Assert Create splunk.es.adaptive_response_notable_event CHANGED
- assert:
+ ansible.builtin.assert:
that:
- adaptive_response_notable_event_out['changed'] == True
- adaptive_response_notable_event_out['failed'] == False
- name: Validate splunk.es.adaptive_response_notable_event idempotent
adaptive_response_notable_event:
- name: "Fake notable event from playbook"
- correlation_search_name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake notable event from playbook, description edition."
- state: "present"
+ name: Fake notable event from playbook
+ correlation_search_name: Test Fake Coorelation Search From Playbook
+ description: Test Fake notable event from playbook, description edition.
+ state: present
next_steps:
- ping
- nslookup
@@ -49,7 +49,7 @@
register: adaptive_response_notable_event_out2
- name: Assert Create splunk.es.adaptive_response_notable_event IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- adaptive_response_notable_event_out2['changed'] == False
- adaptive_response_notable_event_out2['failed'] == False
diff --git a/ansible_collections/splunk/es/tests/integration/targets/correlation_search_info/tasks/main.yml b/ansible_collections/splunk/es/tests/integration/targets/correlation_search_info/tasks/main.yml
index a2ae59ef4..fb49f1d27 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/correlation_search_info/tasks/main.yml
+++ b/ansible_collections/splunk/es/tests/integration/targets/correlation_search_info/tasks/main.yml
@@ -1,74 +1,74 @@
---
- name: Cleanup old correlation_search
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "absent"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: absent
- name: Test correlation_search - CREATE
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "present"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: present
register: correlation_search_create_output
- name: Assert Create splunk.es.correlation_search CHANGED
- assert:
+ ansible.builtin.assert:
that:
- correlation_search_create_output['changed'] == True
- correlation_search_create_output['failed'] == False
- name: Test correlation_search - CREATE IDEMPOTENT
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "present"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: present
register: correlation_search_create_output2
- name: Assert Create splunk.es.correlation_search IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- correlation_search_create_output2['changed'] == False
- correlation_search_create_output2['failed'] == False
- name: Test correlation_search_info
correlation_search_info:
- name: "Test Fake Coorelation Search From Playbook"
+ name: Test Fake Coorelation Search From Playbook
register: correlation_search_info_output
- name: Assert Create splunk.es.correlation_search CHANGED
- assert:
+ ansible.builtin.assert:
that:
- correlation_search_info_output['changed'] == False
- correlation_search_info_output['failed'] == False
- name: Test correlation_search - DELETE
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "absent"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: absent
register: correlation_search_delete_output
- name: Assert Create splunk.es.correlation_search CHANGED
- assert:
+ ansible.builtin.assert:
that:
- correlation_search_delete_output['changed'] == True
- correlation_search_delete_output['failed'] == False
- name: Test correlation_search - DELETE IDEMPOTENT
correlation_search:
- name: "Test Fake Coorelation Search From Playbook"
- description: "Test Fake Coorelation Search From Playbook, description edition."
- search: 'source="/var/log/snort.log"'
- state: "absent"
+ name: Test Fake Coorelation Search From Playbook
+ description: Test Fake Coorelation Search From Playbook, description edition.
+ search: source="/var/log/snort.log"
+ state: absent
register: correlation_search_delete_output2
- name: Assert Create splunk.es.correlation_search IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- correlation_search_delete_output2['changed'] == False
- correlation_search_delete_output2['failed'] == False
diff --git a/ansible_collections/splunk/es/tests/integration/targets/data_input_monitor/tasks/main.yml b/ansible_collections/splunk/es/tests/integration/targets/data_input_monitor/tasks/main.yml
index 87459760e..c82828756 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/data_input_monitor/tasks/main.yml
+++ b/ansible_collections/splunk/es/tests/integration/targets/data_input_monitor/tasks/main.yml
@@ -1,58 +1,58 @@
---
- name: Clean up previous data_input_monitor
data_input_monitor:
- name: "/var/log/messages"
- state: "absent"
- recursive: True
+ name: /var/log/messages
+ state: absent
+ recursive: true
- name: Test data_input_monitor - CREATE
data_input_monitor:
- name: "/var/log/messages"
- state: "present"
- recursive: True
+ name: /var/log/messages
+ state: present
+ recursive: true
register: data_input_monitor_output
- name: Assert Create splunk.es.data_input_monitor CHANGED
- assert:
+ ansible.builtin.assert:
that:
- data_input_monitor_output['changed'] == True
- data_input_monitor_output['failed'] == False
- name: Test data_input_monitor - CREATE IDEMPOTENT
data_input_monitor:
- name: "/var/log/messages"
- state: "present"
- recursive: True
+ name: /var/log/messages
+ state: present
+ recursive: true
register: data_input_monitor_output2
- name: Assert Create splunk.es.data_input_monitor CREATE IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- data_input_monitor_output2['changed'] == False
- data_input_monitor_output2['failed'] == False
- name: Test data_input_monitor - DELETE
data_input_monitor:
- name: "/var/log/messages"
- state: "absent"
- recursive: True
+ name: /var/log/messages
+ state: absent
+ recursive: true
register: data_input_monitor_absent_output
- name: Assert Create splunk.es.data_input_monitor CHANGED
- assert:
+ ansible.builtin.assert:
that:
- data_input_monitor_absent_output['changed'] == True
- data_input_monitor_absent_output['failed'] == False
- name: Test data_input_monitor - DELETE IDEMPOTENT
data_input_monitor:
- name: "/var/log/messages"
- state: "absent"
- recursive: True
+ name: /var/log/messages
+ state: absent
+ recursive: true
register: data_input_monitor_absent_output2
- name: Assert Create splunk.es.data_input_monitor DELETE IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- data_input_monitor_absent_output2['changed'] == False
- data_input_monitor_absent_output2['failed'] == False
diff --git a/ansible_collections/splunk/es/tests/integration/targets/data_input_network/tasks/main.yml b/ansible_collections/splunk/es/tests/integration/targets/data_input_network/tasks/main.yml
index 5082458c0..31f1f611d 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/data_input_network/tasks/main.yml
+++ b/ansible_collections/splunk/es/tests/integration/targets/data_input_network/tasks/main.yml
@@ -2,18 +2,18 @@
- name: Cleanup previous data_input_network
data_input_network:
name: "8099"
- protocol: "tcp"
- state: "absent"
+ protocol: tcp
+ state: absent
- name: Test data_input_network - CREATE
data_input_network:
name: "8099"
- protocol: "tcp"
- state: "present"
+ protocol: tcp
+ state: present
register: data_input_network_output
- name: Assert Create splunk.es.data_input_network CHANGED
- assert:
+ ansible.builtin.assert:
that:
- data_input_network_output is changed
- data_input_network_output is not failed
@@ -21,12 +21,12 @@
- name: Test data_input_network - CREATE IDEMPOTENT
data_input_network:
name: "8099"
- protocol: "tcp"
- state: "present"
+ protocol: tcp
+ state: present
register: data_input_network_output2
- name: Assert Create splunk.es.data_input_network CREATE IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- data_input_network_output2 is not changed
- data_input_network_output2 is not failed
@@ -34,12 +34,12 @@
- name: Test data_input_network - DELETE
data_input_network:
name: "8099"
- protocol: "tcp"
- state: "absent"
+ protocol: tcp
+ state: absent
register: data_input_network_absent_output
- name: Assert Create splunk.es.data_input_network CHANGED
- assert:
+ ansible.builtin.assert:
that:
- data_input_network_absent_output is changed
- data_input_network_absent_output is not failed
@@ -47,12 +47,12 @@
- name: Test data_input_network - DELETE IDEMPOTENT
data_input_network:
name: "8099"
- protocol: "tcp"
- state: "absent"
+ protocol: tcp
+ state: absent
register: data_input_network_absent_output2
- name: Assert Create splunk.es.data_input_network DELETE IDEMPOTENT
- assert:
+ ansible.builtin.assert:
that:
- data_input_network_absent_output2 is not changed
- data_input_network_absent_output2 is not failed
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/defaults/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/defaults/main.yaml
index 10c0fabcb..5f709c5aa 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/defaults/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/defaults/main.yaml
@@ -1,2 +1,2 @@
---
-testcase: '*'
+testcase: "*"
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/cli.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/cli.yaml
index dcc81f25f..c8ca9a326 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/cli.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/cli.yaml
@@ -1,18 +1,19 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
-- name: set test_items
- set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.httpapi)
- include: '{{ test_case_to_run }}'
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.httpapi
- with_items: '{{ test_items }}'
+ with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: connection_httpapi
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/main.yaml
index 62cc1ae1e..098fa1e5a 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/main.yaml
@@ -1,7 +1,7 @@
---
-- include: cli.yaml
+- ansible.builtin._include: cli.yaml
tags:
- cli
-- include: redirection.yaml
+- ansible.builtin._include: redirection.yaml
when: ansible_version.full is version('2.10.0', '>=')
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/redirection.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/redirection.yaml
index bafc23a45..6bab72a07 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/redirection.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tasks/redirection.yaml
@@ -1,6 +1,6 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests/redirection'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/redirection"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tests/_populate_dim_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tests/_populate_dim_config.yaml
index 02e9074da..adaa80481 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tests/_populate_dim_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/tests/_populate_dim_config.yaml
@@ -10,40 +10,40 @@
- name: populate notable event adaptive response for test correlation search
splunk.es.splunk_adaptive_response_notable_events:
config:
- - correlation_search_name: Ansible Test
- description: test notable event
- drilldown_earliest_offset: $info_min_time$
- drilldown_latest_offset: $info_max_time$
- drilldown_name: test_drill_name
- drilldown_search: test_drill
- extract_artifacts:
- asset:
- - src
- - dest
- - dvc
- - orig_host
- identity:
- - src_user
- - user
- - src_user_id
- - src_user_role
- - user_id
- - user_role
- - vendor_account
- investigation_profiles:
- - test profile 1
- - test profile 2
- - test profile 3
- next_steps:
- - makestreams
- - nbtstat
- - nslookup
- name: ansible_test_notable
- recommended_actions:
- - email
- - logevent
- - makestreams
- - nbtstat
- security_domain: threat
- severity: high
- state: merged \ No newline at end of file
+ - correlation_search_name: Ansible Test
+ description: test notable event
+ drilldown_earliest_offset: $info_min_time$
+ drilldown_latest_offset: $info_max_time$
+ drilldown_name: test_drill_name
+ drilldown_search: test_drill
+ extract_artifacts:
+ asset:
+ - src
+ - dest
+ - dvc
+ - orig_host
+ identity:
+ - src_user
+ - user
+ - src_user_id
+ - src_user_role
+ - user_id
+ - user_role
+ - vendor_account
+ investigation_profiles:
+ - test profile 1
+ - test profile 2
+ - test profile 3
+ next_steps:
+ - makestreams
+ - nbtstat
+ - nslookup
+ name: ansible_test_notable
+ recommended_actions:
+ - email
+ - logevent
+ - makestreams
+ - nbtstat
+ security_domain: threat
+ severity: high
+ state: merged
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/vars/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/vars/main.yaml
index 8116add0d..daaaec773 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/vars/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_adaptive_response_notable_events/vars/main.yaml
@@ -1,7 +1,6 @@
---
merged:
before: []
-
after:
- correlation_search_name: Ansible Test
description: test notable event
@@ -10,12 +9,12 @@ merged:
drilldown_name: test_drill_name
drilldown_search: test_drill
extract_artifacts:
- asset:
+ asset:
- src
- dest
- dvc
- orig_host
- identity:
+ identity:
- src_user
- user
- src_user_id
@@ -32,7 +31,7 @@ merged:
- nbtstat
- nslookup
name: ansible_test_notable
- recommended_actions:
+ recommended_actions:
- email
- logevent
- makestreams
@@ -49,12 +48,12 @@ replaced:
drilldown_name: test_drill_name
drilldown_search: test_drill
extract_artifacts:
- asset:
+ asset:
- src
- dest
- dvc
- orig_host
- identity:
+ identity:
- src_user
- user
- src_user_id
@@ -71,7 +70,7 @@ replaced:
- nbtstat
- nslookup
name: ansible_test_notable
- recommended_actions:
+ recommended_actions:
- email
- logevent
- makestreams
@@ -84,18 +83,18 @@ replaced:
drilldown_earliest_offset: $info_min_time$
drilldown_latest_offset: $info_max_time$
extract_artifacts:
- asset:
+ asset:
- src
- dest
- identity:
+ identity:
- src_user
- user
- src_user_id
next_steps:
- makestreams
name: ansible_test_notable
- recommended_actions:
+ recommended_actions:
- email
- logevent
security_domain: threat
- severity: high \ No newline at end of file
+ severity: high
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_populate_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_populate_config.yaml
index 39b507ff3..8a4f2226d 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_populate_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_populate_config.yaml
@@ -33,6 +33,6 @@
throttle_window_duration: 5s
throttle_fields_to_group_by:
- test_field1
- suppress_alerts: False
+ suppress_alerts: false
search: '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authentication.dest") as "dest_count",count from datamodel="Authentication"."Authentication" where nodename="Authentication.Failed_Authentication" by "Authentication.app","Authentication.src" | rename "Authentication.app" as "app","Authentication.src" as "src" | where "count">=6'
- state: merged \ No newline at end of file
+ state: merged
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_remove_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_remove_config.yaml
index 7707f9191..ee1b9020c 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_remove_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/_remove_config.yaml
@@ -3,4 +3,4 @@
splunk.es.splunk_correlation_searches:
config:
- name: Ansible Test
- state: deleted \ No newline at end of file
+ state: deleted
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/merged.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/merged.yaml
index a83d1aacf..d575990e2 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/merged.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/merged.yaml
@@ -1,6 +1,7 @@
---
- debug:
- msg: START Merged correlation_searches state for integration tests on connection={{
+ msg:
+ START Merged correlation_searches state for integration tests on connection={{
ansible_connection }}
- include_tasks: _remove_config.yaml
@@ -43,7 +44,7 @@
throttle_window_duration: 5s
throttle_fields_to_group_by:
- test_field1
- suppress_alerts: False
+ suppress_alerts: false
search: '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authentication.dest") as "dest_count",count from datamodel="Authentication"."Authentication" where nodename="Authentication.Failed_Authentication" by "Authentication.app","Authentication.src" | rename "Authentication.app" as "app","Authentication.src" as "src" | where "count">=6'
- name: Assert that task reports change and after dict is correctly generated
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/replaced.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/replaced.yaml
index a41649a5b..9ac80cc15 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/replaced.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/replaced.yaml
@@ -6,7 +6,6 @@
- include_tasks: _populate_config.yaml
- block:
-
- name: Replace existing correlation searches configuration
register: result
splunk.es.splunk_correlation_searches: &id001
@@ -49,7 +48,7 @@
throttle_fields_to_group_by:
- test_field1
- test_field2
- suppress_alerts: True
+ suppress_alerts: true
search: '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authentication.dest") as "dest_count",count from datamodel="Authentication"."Authentication" where nodename="Authentication.Failed_Authentication" by "Authentication.app","Authentication.src" | rename "Authentication.app" as "app","Authentication.src" as "src" | where "count">=6'
- assert:
@@ -58,8 +57,9 @@
- replaced['before'] == result['correlation_searches']['before']
- replaced['after'] == result['correlation_searches']['after']
- - name: Replaces device configuration of listed data inputs networks configuration with
- provided configuration (IDEMPOTENT)
+ - name:
+ Replaces device configuration of listed data inputs networks configuration with
+ provided configuration (IDEMPOTENT)
register: result
splunk.es.splunk_correlation_searches: *id001
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/rtt.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/rtt.yaml
index 151e7305a..f0124db38 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/rtt.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_correlation_searches/tests/rtt.yaml
@@ -42,7 +42,7 @@
throttle_window_duration: 5s
throttle_fields_to_group_by:
- test_field1
- suppress_alerts: False
+ suppress_alerts: false
search: '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authentication.dest") as "dest_count",count from datamodel="Authentication"."Authentication" where nodename="Authentication.Failed_Authentication" by "Authentication.app","Authentication.src" | rename "Authentication.app" as "app","Authentication.src" as "src" | where "count">=6'
- name: Gather correlation searches configuration facts
@@ -93,7 +93,7 @@
throttle_fields_to_group_by:
- test_field1
- test_field2
- suppress_alerts: True
+ suppress_alerts: true
search: '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authentication.dest") as "dest_count",count from datamodel="Authentication"."Authentication" where nodename="Authentication.Failed_Authentication" by "Authentication.app","Authentication.src" | rename "Authentication.app" as "app","Authentication.src" as "src" | where "count">=6'
state: replaced
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/defaults/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/defaults/main.yaml
index 10c0fabcb..5f709c5aa 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/defaults/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/defaults/main.yaml
@@ -1,2 +1,2 @@
---
-testcase: '*'
+testcase: "*"
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/cli.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/cli.yaml
index dcc81f25f..c8ca9a326 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/cli.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/cli.yaml
@@ -1,18 +1,19 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
-- name: set test_items
- set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.httpapi)
- include: '{{ test_case_to_run }}'
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.httpapi
- with_items: '{{ test_items }}'
+ with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: connection_httpapi
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/main.yaml
index 62cc1ae1e..098fa1e5a 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/main.yaml
@@ -1,7 +1,7 @@
---
-- include: cli.yaml
+- ansible.builtin._include: cli.yaml
tags:
- cli
-- include: redirection.yaml
+- ansible.builtin._include: redirection.yaml
when: ansible_version.full is version('2.10.0', '>=')
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/redirection.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/redirection.yaml
index bafc23a45..6bab72a07 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/redirection.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tasks/redirection.yaml
@@ -1,6 +1,6 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests/redirection'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/redirection"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_populate_dim_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_populate_dim_config.yaml
index 2bb0129a4..c5935e460 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_populate_dim_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_populate_dim_config.yaml
@@ -4,19 +4,19 @@
config:
- name: "/var/log"
blacklist: '/\/var\/log\/[a-z]/gm'
- check_index: True
- check_path: True
+ check_index: true
+ check_path: true
crc_salt: <SOURCE>
- disabled: False
- follow_tail: False
+ disabled: false
+ follow_tail: false
host: "$decideOnStartup"
host_regex: "/(test_host)/gm"
host_segment: 3
ignore_older_than: 5d
index: default
- recursive: True
+ recursive: true
rename_source: test
sourcetype: test_source_type
time_before_close: 4
whitelist: '/\/var\/log\/[a-z]/gm'
- state: merged \ No newline at end of file
+ state: merged
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_remove_dim_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_remove_dim_config.yaml
index d0fdb2d90..ca3308f11 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_remove_dim_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/_remove_dim_config.yaml
@@ -3,4 +3,4 @@
splunk.es.splunk_data_inputs_monitor:
config:
- name: "/var/log"
- state: deleted \ No newline at end of file
+ state: deleted
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/deleted.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/deleted.yaml
index 8f19b500f..4cbac1c04 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/deleted.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/deleted.yaml
@@ -1,6 +1,7 @@
---
- debug:
- msg: Start Deleted integration state for data_inputs_monitors ansible_connection={{ ansible_connection
+ msg:
+ Start Deleted integration state for data_inputs_monitors ansible_connection={{ ansible_connection
}}
- include_tasks: _remove_dim_config.yaml
@@ -14,7 +15,7 @@
- name: /var/log
state: deleted
register: result
-
+
- assert:
that:
- result.changed == true
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/merged.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/merged.yaml
index 0388c26c1..5ad0c8bad 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/merged.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/merged.yaml
@@ -1,6 +1,7 @@
---
- debug:
- msg: START Merged data_inputs_monitor state for integration tests on connection={{
+ msg:
+ START Merged data_inputs_monitor state for integration tests on connection={{
ansible_connection }}
- include_tasks: _remove_dim_config.yaml
@@ -14,17 +15,17 @@
config:
- name: "/var/log"
blacklist: '/\/var\/log\/[a-z]/gm'
- check_index: True
- check_path: True
+ check_index: true
+ check_path: true
crc_salt: <SOURCE>
- disabled: False
- follow_tail: False
+ disabled: false
+ follow_tail: false
host: "$decideOnStartup"
host_regex: "/(test_host)/gm"
host_segment: 3
ignore_older_than: 5d
index: default
- recursive: True
+ recursive: true
rename_source: test
sourcetype: test_source_type
time_before_close: 4
@@ -53,5 +54,4 @@
- result['changed'] == false
always:
-
- - include_tasks: _remove_dim_config.yaml \ No newline at end of file
+ - include_tasks: _remove_dim_config.yaml
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/replaced.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/replaced.yaml
index 7a9dd8c46..e2435f2ce 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/replaced.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/replaced.yaml
@@ -1,13 +1,13 @@
---
- debug:
- msg: START Replaced data_inputs_monitor state for integration tests on connection={{ ansible_connection
+ msg:
+ START Replaced data_inputs_monitor state for integration tests on connection={{ ansible_connection
}}
- include_tasks: _remove_dim_config.yaml
- include_tasks: _populate_dim_config.yaml
- block:
-
- name: Replace existing data inputs monitors configuration
register: result
splunk.es.splunk_data_inputs_monitor: &id001
@@ -17,7 +17,6 @@
blacklist: '/\/var\/log\/[a-z0-9]/gm'
crc_salt: <SOURCE>
-
- assert:
that:
- result.changed == true
@@ -28,8 +27,9 @@
symmetric_difference(result['data_inputs_monitor']['after'][0] |\
dict2items) | length==3}}"
- - name: Replaces device configuration of listed data inputs networks configuration with
- provided configuration (IDEMPOTENT)
+ - name:
+ Replaces device configuration of listed data inputs networks configuration with
+ provided configuration (IDEMPOTENT)
register: result
splunk.es.splunk_data_inputs_monitor: *id001
@@ -39,5 +39,4 @@
- result['changed'] == false
always:
-
- include_tasks: _remove_dim_config.yaml
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/rtt.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/rtt.yaml
index 4025c446c..79904a72b 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/rtt.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/tests/rtt.yaml
@@ -6,7 +6,6 @@
- include_tasks: _populate_dim_config.yaml
- block:
-
- name: Apply the provided configuration (base config)
register: base_config
splunk.es.splunk_data_inputs_monitor: &id001
@@ -14,17 +13,17 @@
config:
- name: "/var/log"
blacklist: '/\/var\/log\/[a-z]/gm'
- check_index: True
- check_path: True
+ check_index: true
+ check_path: true
crc_salt: <SOURCE>
- disabled: False
- follow_tail: False
+ disabled: false
+ follow_tail: false
host: "$decideOnStartup"
host_regex: "/(test_host)/gm"
host_segment: 3
ignore_older_than: 5d
index: default
- recursive: True
+ recursive: true
rename_source: test
sourcetype: test_source_type
time_before_close: 4
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/vars/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/vars/main.yaml
index 881a750b4..87747ada4 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/vars/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_monitor/vars/main.yaml
@@ -1,46 +1,45 @@
---
merged:
before: []
-
after:
- name: "/var/log"
- blacklist: '/\/var\/log\/[a-z]/gm'
- check_index: True
- check_path: True
+ name: /var/log
+ blacklist: /\/var\/log\/[a-z]/gm
+ check_index: true
+ check_path: true
crc_salt: <SOURCE>
- disabled: False
- follow_tail: False
- host: "$decideOnStartup"
- host_regex: "/(test_host)/gm"
+ disabled: false
+ follow_tail: false
+ host: $decideOnStartup
+ host_regex: /(test_host)/gm
host_segment: 3
ignore_older_than: 5d
index: default
- recursive: True
+ recursive: true
rename_source: test
sourcetype: test_source_type
time_before_close:
- whitelist: '/\/var\/log\/[a-z]/gm'
+ whitelist: /\/var\/log\/[a-z]/gm
replaced:
before:
- name: "/var/log"
- blacklist: '/\/var\/log\/[a-z]/gm'
- check_index: True
- check_path: True
+ name: /var/log
+ blacklist: /\/var\/log\/[a-z]/gm
+ check_index: true
+ check_path: true
crc_salt: <SOURCE>
- disabled: False
- follow_tail: False
- host: "$decideOnStartup"
- host_regex: "/(test_host)/gm"
+ disabled: false
+ follow_tail: false
+ host: $decideOnStartup
+ host_regex: /(test_host)/gm
host_segment: 3
ignore_older_than: 5d
index: default
- recursive: True
+ recursive: true
rename_source: test
sourcetype: test_source_type
time_before_close:
- whitelist: '/\/var\/log\/[a-z]/gm'
+ whitelist: /\/var\/log\/[a-z]/gm
after:
- name: "/var/log"
- blacklist: '/\/var\/log\/[a-z0-9]/gm'
- crc_salt: <SOURCE> \ No newline at end of file
+ name: /var/log
+ blacklist: /\/var\/log\/[a-z0-9]/gm
+ crc_salt: <SOURCE>
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/defaults/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/defaults/main.yaml
index 10c0fabcb..5f709c5aa 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/defaults/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/defaults/main.yaml
@@ -1,2 +1,2 @@
---
-testcase: '*'
+testcase: "*"
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/cli.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/cli.yaml
index dcc81f25f..c8ca9a326 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/cli.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/cli.yaml
@@ -1,18 +1,19 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
-- name: set test_items
- set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.httpapi)
- include: '{{ test_case_to_run }}'
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.httpapi
- with_items: '{{ test_items }}'
+ with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: connection_httpapi
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/main.yaml
index 62cc1ae1e..098fa1e5a 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/main.yaml
@@ -1,7 +1,7 @@
---
-- include: cli.yaml
+- ansible.builtin._include: cli.yaml
tags:
- cli
-- include: redirection.yaml
+- ansible.builtin._include: redirection.yaml
when: ansible_version.full is version('2.10.0', '>=')
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/redirection.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/redirection.yaml
index bafc23a45..6bab72a07 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/redirection.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tasks/redirection.yaml
@@ -1,6 +1,6 @@
---
-- name: collect all test cases
- find:
- paths: '{{ role_path }}/tests/redirection'
- patterns: '{{ testcase }}.yaml'
+- name: Collect all test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/redirection"
+ patterns: "{{ testcase }}.yaml"
register: test_cases
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_populate_din_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_populate_din_config.yaml
index 60f87afbf..9fb608dd4 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_populate_din_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_populate_din_config.yaml
@@ -6,7 +6,7 @@
datatype: raw
name: 8100
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
queue: parsingQueue
@@ -18,7 +18,7 @@
datatype: cooked
name: 8101
connection_host: ip
- disabled: False
+ disabled: false
host: "$decideOnStartup"
restrict_to_host: default
- protocol: tcp
@@ -31,13 +31,13 @@
- protocol: udp
name: 7890
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
- no_appending_timestamp: True
- no_priority_stripping: True
+ no_appending_timestamp: true
+ no_priority_stripping: true
queue: parsingQueue
restrict_to_host: default
source: test_source
sourcetype: test_source_type
- state: merged \ No newline at end of file
+ state: merged
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_remove_din_config.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_remove_din_config.yaml
index bf904c27d..62c42c5e7 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_remove_din_config.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/_remove_din_config.yaml
@@ -13,4 +13,4 @@
name: test_token
- protocol: udp
name: default:7890
- state: deleted \ No newline at end of file
+ state: deleted
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/merged.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/merged.yaml
index 842524ec6..2fcdaa9db 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/merged.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/merged.yaml
@@ -17,7 +17,7 @@
datatype: raw
name: 8100
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
queue: parsingQueue
@@ -29,7 +29,7 @@
datatype: cooked
name: 8101
connection_host: ip
- disabled: False
+ disabled: false
host: "$decideOnStartup"
restrict_to_host: default
- protocol: tcp
@@ -42,11 +42,11 @@
- protocol: udp
name: 7890
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
- no_appending_timestamp: True
- no_priority_stripping: True
+ no_appending_timestamp: true
+ no_priority_stripping: true
queue: parsingQueue
restrict_to_host: default
source: test_source
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/replaced.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/replaced.yaml
index 340df5282..2f261efb9 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/replaced.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/replaced.yaml
@@ -17,7 +17,7 @@
datatype: raw
name: 8100
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
queue: parsingQueue
@@ -29,7 +29,7 @@
datatype: cooked
name: 8101
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
restrict_to_host: default
- protocol: tcp
@@ -39,11 +39,11 @@
- protocol: udp
name: 7890
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
- no_appending_timestamp: False
- no_priority_stripping: False
+ no_appending_timestamp: false
+ no_priority_stripping: false
queue: parsingQueue
restrict_to_host: default
source: test_source
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/rtt.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/rtt.yaml
index 1fa3e577c..4ad739da5 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/rtt.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/tests/rtt.yaml
@@ -17,7 +17,7 @@
datatype: raw
name: 8100
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
queue: parsingQueue
@@ -29,7 +29,7 @@
datatype: cooked
name: 8101
connection_host: ip
- disabled: False
+ disabled: false
host: "$decideOnStartup"
restrict_to_host: default
- protocol: tcp
@@ -39,11 +39,11 @@
- protocol: udp
name: 7890
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
- no_appending_timestamp: True
- no_priority_stripping: True
+ no_appending_timestamp: true
+ no_priority_stripping: true
queue: parsingQueue
restrict_to_host: default
source: test_source
@@ -74,7 +74,7 @@
datatype: raw
name: 8100
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
queue: parsingQueue
@@ -86,7 +86,7 @@
datatype: cooked
name: 8101
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
restrict_to_host: default
- protocol: tcp
@@ -96,11 +96,11 @@
- protocol: udp
name: 7890
connection_host: ip
- disabled: True
+ disabled: true
host: "$decideOnStartup"
index: default
- no_appending_timestamp: False
- no_priority_stripping: False
+ no_appending_timestamp: false
+ no_priority_stripping: false
queue: parsingQueue
restrict_to_host: default
source: test_source
diff --git a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/vars/main.yaml b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/vars/main.yaml
index 942b75851..46b42f7e2 100644
--- a/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/vars/main.yaml
+++ b/ansible_collections/splunk/es/tests/integration/targets/splunk_data_inputs_network/vars/main.yaml
@@ -15,7 +15,7 @@ merged:
datatype: raw
name: default:8100
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
queue: parsingQueue
@@ -27,13 +27,13 @@ merged:
datatype: cooked
name: default:8101
connection_host: ip
- disabled: False
+ disabled: false
host: $decideOnStartup
restrict_to_host: default
- protocol: tcp
datatype: splunktcptoken
name: splunktcptoken://test_token
- token: 01234567-0123-0123-0123-012345678901
+ token: "01234567-0123-0123-0123-012345678901"
- protocol: tcp
datatype: ssl
name: test_host
@@ -44,11 +44,11 @@ merged:
- protocol: udp
name: default:7890
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
- no_appending_timestamp: True
- no_priority_stripping: True
+ no_appending_timestamp: true
+ no_priority_stripping: true
queue: parsingQueue
restrict_to_host: default
source: test_source
@@ -60,7 +60,7 @@ replaced:
datatype: raw
name: default:8100
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
queue: parsingQueue
@@ -72,21 +72,21 @@ replaced:
datatype: cooked
name: default:8101
connection_host: ip
- disabled: False
+ disabled: false
host: $decideOnStartup
restrict_to_host: default
- protocol: tcp
datatype: splunktcptoken
name: splunktcptoken://test_token
- token: 01234567-0123-0123-0123-012345678901
+ token: "01234567-0123-0123-0123-012345678901"
- protocol: udp
name: default:7890
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
- no_appending_timestamp: True
- no_priority_stripping: True
+ no_appending_timestamp: true
+ no_priority_stripping: true
queue: parsingQueue
restrict_to_host: default
source: test_source
@@ -96,7 +96,7 @@ replaced:
datatype: raw
name: default:8100
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
queue: parsingQueue
@@ -108,21 +108,21 @@ replaced:
datatype: cooked
name: default:8101
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
restrict_to_host: default
- protocol: tcp
datatype: splunktcptoken
name: splunktcptoken://test_token
- token: 01234567-0123-0123-0123-012345678900
+ token: "01234567-0123-0123-0123-012345678900"
- protocol: udp
name: default:7890
connection_host: ip
- disabled: True
+ disabled: true
host: $decideOnStartup
index: default
- no_appending_timestamp: False
- no_priority_stripping: False
+ no_appending_timestamp: false
+ no_priority_stripping: false
queue: parsingQueue
restrict_to_host: default
source: test_source
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.12.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.12.txt
new file mode 100644
index 000000000..0cd1efee7
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.12.txt
@@ -0,0 +1 @@
+tests/unit/mock/loader.py pylint:arguments-renamed
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.13.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.13.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.13.txt
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.14.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.14.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.14.txt
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.15.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.15.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.15.txt
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.16.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.16.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.16.txt
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.17.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.17.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.17.txt
diff --git a/ansible_collections/splunk/es/tests/sanity/ignore-2.9.txt b/ansible_collections/splunk/es/tests/sanity/ignore-2.9.txt
index ed0da94eb..16dfcae4d 100644
--- a/ansible_collections/splunk/es/tests/sanity/ignore-2.9.txt
+++ b/ansible_collections/splunk/es/tests/sanity/ignore-2.9.txt
@@ -6,4 +6,4 @@ plugins/modules/data_input_monitor.py validate-modules:invalid-documentation
plugins/modules/data_input_network.py validate-modules:deprecation-mismatch
plugins/modules/data_input_network.py validate-modules:invalid-documentation
plugins/modules/adaptive_response_notable_event.py validate-modules:deprecation-mismatch
-plugins/modules/adaptive_response_notable_event.py validate-modules:invalid-documentation \ No newline at end of file
+plugins/modules/adaptive_response_notable_event.py validate-modules:invalid-documentation
diff --git a/ansible_collections/splunk/es/tests/unit/compat/builtins.py b/ansible_collections/splunk/es/tests/unit/compat/builtins.py
deleted file mode 100644
index bfc8adfbe..000000000
--- a/ansible_collections/splunk/es/tests/unit/compat/builtins.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-#
-# Compat for python2.7
-#
-
-# One unittest needs to import builtins via __import__() so we need to have
-# the string that represents it
-try:
- import __builtin__
-except ImportError:
- BUILTINS = "builtins"
-else:
- BUILTINS = "__builtin__"
diff --git a/ansible_collections/splunk/es/tests/unit/compat/mock.py b/ansible_collections/splunk/es/tests/unit/compat/mock.py
index 2ea98a17f..61ac88700 100644
--- a/ansible_collections/splunk/es/tests/unit/compat/mock.py
+++ b/ansible_collections/splunk/es/tests/unit/compat/mock.py
@@ -19,6 +19,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
"""
@@ -26,6 +27,7 @@ Compat module for Python3.x's unittest.mock module
"""
import sys
+
# Python 2.7
# Note: Could use the pypi mock library on python3.x as well as python2.x. It
@@ -104,7 +106,7 @@ if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
import _io
file_spec = list(
- set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))
+ set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))),
)
if mock is None:
diff --git a/ansible_collections/splunk/es/tests/unit/compat/unittest.py b/ansible_collections/splunk/es/tests/unit/compat/unittest.py
index df3379b82..df4266ec9 100644
--- a/ansible_collections/splunk/es/tests/unit/compat/unittest.py
+++ b/ansible_collections/splunk/es/tests/unit/compat/unittest.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
"""
@@ -26,6 +27,7 @@ Compat module for Python2.7's unittest module
import sys
+
# Allow wildcard import because we really do want to import all of
# unittests's symbols into this compat shim
# pylint: disable=wildcard-import,unused-wildcard-import
diff --git a/ansible_collections/splunk/es/tests/unit/mock/loader.py b/ansible_collections/splunk/es/tests/unit/mock/loader.py
index 19c44a7e8..011c67b29 100644
--- a/ansible_collections/splunk/es/tests/unit/mock/loader.py
+++ b/ansible_collections/splunk/es/tests/unit/mock/loader.py
@@ -18,19 +18,20 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import os
from ansible.errors import AnsibleParserError
-from ansible.parsing.dataloader import DataLoader
from ansible.module_utils._text import to_bytes, to_text
+from ansible.parsing.dataloader import DataLoader
class DictDataLoader(DataLoader):
def __init__(self, file_mapping=None):
file_mapping = {} if file_mapping is None else file_mapping
- assert type(file_mapping) == dict
+ assert isinstance(file_mapping, dict)
super(DictDataLoader, self).__init__()
diff --git a/ansible_collections/splunk/es/tests/unit/mock/path.py b/ansible_collections/splunk/es/tests/unit/mock/path.py
index 1e5902864..06f1a3d56 100644
--- a/ansible_collections/splunk/es/tests/unit/mock/path.py
+++ b/ansible_collections/splunk/es/tests/unit/mock/path.py
@@ -1,12 +1,13 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
-from ansible_collections.trendmicro.deepsec.tests.unit.compat.mock import (
- MagicMock,
-)
from ansible.utils.path import unfrackpath
+from ansible_collections.splunk.es.tests.unit.compat.mock import MagicMock
+
mock_unfrackpath_noop = MagicMock(
- spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x
+ spec_set=unfrackpath,
+ side_effect=lambda x, *args, **kwargs: x,
)
diff --git a/ansible_collections/splunk/es/tests/unit/mock/procenv.py b/ansible_collections/splunk/es/tests/unit/mock/procenv.py
index f7ab5fe91..3699c6308 100644
--- a/ansible_collections/splunk/es/tests/unit/mock/procenv.py
+++ b/ansible_collections/splunk/es/tests/unit/mock/procenv.py
@@ -19,16 +19,19 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
-import sys
import json
+import sys
from contextlib import contextmanager
from io import BytesIO, StringIO
-from ansible_collections.trendmicro.deepsec.tests.unit.compat import unittest
-from ansible.module_utils.six import PY3
+
from ansible.module_utils._text import to_bytes
+from ansible.module_utils.six import PY3
+
+from ansible_collections.splunk.es.tests.unit.compat import unittest
@contextmanager
diff --git a/ansible_collections/splunk/es/tests/unit/mock/vault_helper.py b/ansible_collections/splunk/es/tests/unit/mock/vault_helper.py
index b34ae1340..82d01f5c5 100644
--- a/ansible_collections/splunk/es/tests/unit/mock/vault_helper.py
+++ b/ansible_collections/splunk/es/tests/unit/mock/vault_helper.py
@@ -14,10 +14,10 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils._text import to_bytes
-
from ansible.parsing.vault import VaultSecret
@@ -38,5 +38,7 @@ class TextVaultSecret(VaultSecret):
def bytes(self):
"""The text encoded with encoding, unless we specifically set _bytes."""
return self._bytes or to_bytes(
- self.text, encoding=self.encoding, errors=self.errors
+ self.text,
+ encoding=self.encoding,
+ errors=self.errors,
)
diff --git a/ansible_collections/splunk/es/tests/unit/mock/yaml_helper.py b/ansible_collections/splunk/es/tests/unit/mock/yaml_helper.py
index 5df30aaed..e46d3180b 100644
--- a/ansible_collections/splunk/es/tests/unit/mock/yaml_helper.py
+++ b/ansible_collections/splunk/es/tests/unit/mock/yaml_helper.py
@@ -1,12 +1,14 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import io
+
import yaml
from ansible.module_utils.six import PY3
-from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.parsing.yaml.dumper import AnsibleDumper
+from ansible.parsing.yaml.loader import AnsibleLoader
class YamlTestUtils(object):
@@ -45,7 +47,8 @@ class YamlTestUtils(object):
# dump the gen 2 objects directory to strings
string_from_object_dump_2 = self._dump_string(
- obj_2, dumper=AnsibleDumper
+ obj_2,
+ dumper=AnsibleDumper,
)
# The gen 1 and gen 2 yaml strings
@@ -59,7 +62,8 @@ class YamlTestUtils(object):
obj_3 = loader_3.get_data()
string_from_object_dump_3 = self._dump_string(
- obj_3, dumper=AnsibleDumper
+ obj_3,
+ dumper=AnsibleDumper,
)
self.assertEqual(obj, obj_3)
@@ -93,10 +97,14 @@ class YamlTestUtils(object):
if PY3:
yaml.dump(
- obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper
+ obj_from_stream,
+ stream_obj_from_stream,
+ Dumper=AnsibleDumper,
)
yaml.dump(
- obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper
+ obj_from_stream,
+ stream_obj_from_string,
+ Dumper=AnsibleDumper,
)
else:
yaml.dump(
@@ -120,25 +128,27 @@ class YamlTestUtils(object):
if PY3:
yaml_string_obj_from_stream = yaml.dump(
- obj_from_stream, Dumper=AnsibleDumper
+ obj_from_stream,
+ Dumper=AnsibleDumper,
)
yaml_string_obj_from_string = yaml.dump(
- obj_from_string, Dumper=AnsibleDumper
+ obj_from_string,
+ Dumper=AnsibleDumper,
)
else:
yaml_string_obj_from_stream = yaml.dump(
- obj_from_stream, Dumper=AnsibleDumper, encoding=None
+ obj_from_stream,
+ Dumper=AnsibleDumper,
+ encoding=None,
)
yaml_string_obj_from_string = yaml.dump(
- obj_from_string, Dumper=AnsibleDumper, encoding=None
+ obj_from_string,
+ Dumper=AnsibleDumper,
+ encoding=None,
)
assert yaml_string == yaml_string_obj_from_stream
- assert (
- yaml_string
- == yaml_string_obj_from_stream
- == yaml_string_obj_from_string
- )
+ assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
assert (
yaml_string
== yaml_string_obj_from_stream
diff --git a/ansible_collections/splunk/es/tests/unit/modules/conftest.py b/ansible_collections/splunk/es/tests/unit/modules/conftest.py
index e19a1e04c..349e71ada 100644
--- a/ansible_collections/splunk/es/tests/unit/modules/conftest.py
+++ b/ansible_collections/splunk/es/tests/unit/modules/conftest.py
@@ -2,15 +2,16 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
import pytest
-from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import string_types
@pytest.fixture
@@ -21,20 +22,13 @@ def patch_ansible_module(request, mocker):
if "ANSIBLE_MODULE_ARGS" not in request.param:
request.param = {"ANSIBLE_MODULE_ARGS": request.param}
if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]:
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_remote_tmp"
- ] = "/tmp"
- if (
- "_ansible_keep_remote_files"
- not in request.param["ANSIBLE_MODULE_ARGS"]
- ):
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_keep_remote_files"
- ] = False
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_remote_tmp"] = "/tmp"
+ if "_ansible_keep_remote_files" not in request.param["ANSIBLE_MODULE_ARGS"]:
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_keep_remote_files"] = False
args = json.dumps(request.param)
else:
raise Exception(
- "Malformed data to the patch_ansible_module pytest fixture"
+ "Malformed data to the patch_ansible_module pytest fixture",
)
mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args))
diff --git a/ansible_collections/splunk/es/tests/unit/modules/utils.py b/ansible_collections/splunk/es/tests/unit/modules/utils.py
index d55afc0b3..923594463 100644
--- a/ansible_collections/splunk/es/tests/unit/modules/utils.py
+++ b/ansible_collections/splunk/es/tests/unit/modules/utils.py
@@ -1,13 +1,15 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
-from ansible_collections.trendmicro.deepsec.tests.unit.compat import unittest
-from ansible_collections.trendmicro.deepsec.tests.unit.compat.mock import patch
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
+from ansible_collections.splunk.es.tests.unit.compat import unittest
+from ansible_collections.splunk.es.tests.unit.compat.mock import patch
+
def set_module_args(args):
if "_ansible_remote_tmp" not in args:
@@ -41,7 +43,9 @@ def fail_json(*args, **kwargs):
class ModuleTestCase(unittest.TestCase):
def setUp(self):
self.mock_module = patch.multiple(
- basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json
+ basic.AnsibleModule,
+ exit_json=exit_json,
+ fail_json=fail_json,
)
self.mock_module.start()
self.mock_sleep = patch("time.sleep")
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_adaptive_response_notable_events.py b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_adaptive_response_notable_events.py
index b6a84fc78..96993c6dc 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_adaptive_response_notable_events.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_adaptive_response_notable_events.py
@@ -18,27 +18,27 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils.six import PY2
+
builtin_import = "builtins.__import__"
if PY2:
builtin_import = "__builtin__.__import__"
import tempfile
+
from ansible.playbook.task import Task
from ansible.template import Templar
+from ansible_collections.ansible.utils.tests.unit.compat.mock import MagicMock, patch
+
from ansible_collections.splunk.es.plugins.action.splunk_adaptive_response_notable_events import (
ActionModule,
)
-from ansible_collections.splunk.es.plugins.module_utils.splunk import (
- SplunkRequest,
-)
-from ansible_collections.ansible.utils.tests.unit.compat.mock import (
- MagicMock,
- patch,
-)
+from ansible_collections.splunk.es.plugins.module_utils.splunk import SplunkRequest
+
RESPONSE_PAYLOAD = [
{
@@ -68,8 +68,8 @@ RESPONSE_PAYLOAD = [
"actions": "notable",
},
"name": "Ansible Test",
- }
- ]
+ },
+ ],
},
{
"entry": [
@@ -97,8 +97,8 @@ RESPONSE_PAYLOAD = [
"actions": "notable",
},
"name": "Ansible Test",
- }
- ]
+ },
+ ],
},
]
@@ -153,7 +153,7 @@ REQUEST_PAYLOAD = [
class TestSplunkEsAdaptiveResponseNotableEvents:
- def setup(self):
+ def setup_method(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
@@ -161,7 +161,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = patch(
- "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection"
+ "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection",
)
connection._socket_path = tempfile.NamedTemporaryFile().name
fake_loader = {}
@@ -186,8 +186,39 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
}
@patch("ansible.module_utils.connection.Connection.__rpc__")
+ def test_es_adaptive_response_notable_events_merged_idempotent(
+ self,
+ conn,
+ monkeypatch,
+ ):
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
+ self._plugin._connection._shell = MagicMock()
+
+ def create_update(self, rest_path, data=None):
+ return RESPONSE_PAYLOAD[0]
+
+ def get_by_path(self, path):
+ return RESPONSE_PAYLOAD[0]
+
+ monkeypatch.setattr(SplunkRequest, "create_update", create_update)
+ monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
+
+ self._plugin._task.args = {
+ "state": "merged",
+ "config": [REQUEST_PAYLOAD[0]],
+ }
+ result = self._plugin.run(task_vars=self._task_vars)
+ # recheck with module
+ assert (
+ result["adaptive_response_notable_events"]["before"][0]["correlation_search_name"]
+ == "Ansible Test"
+ )
+
+ @patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_merged_01(
- self, connection, monkeypatch
+ self,
+ connection,
+ monkeypatch,
):
metadata = {
"search": '| tstats summariesonly=true values("Authentication.tag") as "tag",dc("Authentication.user") as "user_count",dc("Authent'
@@ -205,9 +236,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "merged",
@@ -218,7 +247,9 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_merged_02(
- self, connection, monkeypatch
+ self,
+ connection,
+ monkeypatch,
):
self._plugin.api_response = RESPONSE_PAYLOAD[0]
self._plugin.search_for_resource_name = MagicMock()
@@ -232,9 +263,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "merged",
@@ -245,37 +274,12 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
assert result["changed"] is True
@patch("ansible.module_utils.connection.Connection.__rpc__")
- def test_es_adaptive_response_notable_events_merged_idempotent(
- self, conn, monkeypatch
- ):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
- self._plugin._connection._shell = MagicMock()
-
- def create_update(self, rest_path, data=None):
- return RESPONSE_PAYLOAD[0]
-
- def get_by_path(self, path):
- return RESPONSE_PAYLOAD[0]
-
- monkeypatch.setattr(SplunkRequest, "create_update", create_update)
- monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
-
- self._plugin._task.args = {
- "state": "merged",
- "config": [REQUEST_PAYLOAD[0]],
- }
- result = self._plugin.run(task_vars=self._task_vars)
- assert result["changed"] is False
-
- @patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_replaced_01(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = (
@@ -305,11 +309,11 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_replaced_02(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = (
@@ -339,11 +343,11 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_replaced_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(self, rest_path, data=None):
@@ -360,16 +364,18 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
"config": [REQUEST_PAYLOAD[0]],
}
result = self._plugin.run(task_vars=self._task_vars)
-
- assert result["changed"] is False
+ assert (
+ result["adaptive_response_notable_events"]["before"][0]["correlation_search_name"]
+ == "Ansible Test"
+ )
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_deleted(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
@@ -388,7 +394,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
"config": [
{
"correlation_search_name": "Ansible Test",
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
@@ -397,11 +403,10 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_deleted_idempotent(
- self, connection
+ self,
+ connection,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = {}, {}
@@ -411,7 +416,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
"config": [
{
"correlation_search_name": "Ansible Test",
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
@@ -419,11 +424,11 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_adaptive_response_notable_events_gathered(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = (
@@ -436,7 +441,7 @@ class TestSplunkEsAdaptiveResponseNotableEvents:
"config": [
{
"correlation_search_name": "Ansible Test",
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_correlation_searches.py b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_correlation_searches.py
index fca268c98..92e994747 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_correlation_searches.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_correlation_searches.py
@@ -18,27 +18,25 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils.six import PY2
+
builtin_import = "builtins.__import__"
if PY2:
builtin_import = "__builtin__.__import__"
import tempfile
+
from ansible.playbook.task import Task
from ansible.template import Templar
-from ansible_collections.splunk.es.plugins.action.splunk_correlation_searches import (
- ActionModule,
-)
-from ansible_collections.splunk.es.plugins.module_utils.splunk import (
- SplunkRequest,
-)
-from ansible_collections.ansible.utils.tests.unit.compat.mock import (
- MagicMock,
- patch,
-)
+from ansible_collections.ansible.utils.tests.unit.compat.mock import MagicMock, patch
+
+from ansible_collections.splunk.es.plugins.action.splunk_correlation_searches import ActionModule
+from ansible_collections.splunk.es.plugins.module_utils.splunk import SplunkRequest
+
RESPONSE_PAYLOAD = {
"entry": [
@@ -73,8 +71,8 @@ RESPONSE_PAYLOAD = {
'n.src" as "src" | where "count">=6',
},
"name": "Ansible Test",
- }
- ]
+ },
+ ],
}
REQUEST_PAYLOAD = [
@@ -92,7 +90,7 @@ REQUEST_PAYLOAD = [
{
"framework": "test_framework",
"custom_annotations": ["test5"],
- }
+ },
],
},
"ui_dispatch_context": "SplunkEnterpriseSecuritySuite",
@@ -128,7 +126,7 @@ REQUEST_PAYLOAD = [
{
"framework": "test_framework2",
"custom_annotations": ["test9", "test10"],
- }
+ },
],
},
"ui_dispatch_context": "SplunkEnterpriseSecuritySuite",
@@ -154,7 +152,7 @@ REQUEST_PAYLOAD = [
class TestSplunkEsCorrelationSearches:
- def setup(self):
+ def setup_method(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
@@ -162,9 +160,9 @@ class TestSplunkEsCorrelationSearches:
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = patch(
- "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection"
+ "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection",
)
- connection._socket_path = tempfile.NamedTemporaryFile().name
+ # connection._socket_path = tempfile.NamedTemporaryFile().name
fake_loader = {}
templar = Templar(loader=fake_loader)
self._plugin = ActionModule(
@@ -190,9 +188,7 @@ class TestSplunkEsCorrelationSearches:
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "merged",
@@ -203,11 +199,11 @@ class TestSplunkEsCorrelationSearches:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_merged_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(self, rest_path, data=None):
@@ -224,13 +220,12 @@ class TestSplunkEsCorrelationSearches:
"config": [REQUEST_PAYLOAD[0]],
}
result = self._plugin.run(task_vars=self._task_vars)
+ # recheck with module
assert result["changed"] is False
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_replaced_01(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = RESPONSE_PAYLOAD
@@ -257,9 +252,7 @@ class TestSplunkEsCorrelationSearches:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_replaced_02(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = RESPONSE_PAYLOAD
@@ -286,11 +279,11 @@ class TestSplunkEsCorrelationSearches:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_replaced_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(self, rest_path, data=None):
@@ -312,13 +305,11 @@ class TestSplunkEsCorrelationSearches:
}
result = self._plugin.run(task_vars=self._task_vars)
- assert result["changed"] is False
+ assert result["changed"] is True
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_deleted(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def get_by_path(self, path):
@@ -342,9 +333,7 @@ class TestSplunkEsCorrelationSearches:
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = {}
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "deleted",
@@ -355,9 +344,7 @@ class TestSplunkEsCorrelationSearches:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_correlation_searches_gathered(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def get_by_path(self, path):
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_monitors.py b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_monitors.py
index 068fe638d..c6b07baae 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_monitors.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_monitors.py
@@ -18,27 +18,25 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils.six import PY2
+
builtin_import = "builtins.__import__"
if PY2:
builtin_import = "__builtin__.__import__"
import tempfile
+
from ansible.playbook.task import Task
from ansible.template import Templar
-from ansible_collections.splunk.es.plugins.action.splunk_data_inputs_monitor import (
- ActionModule,
-)
-from ansible_collections.splunk.es.plugins.module_utils.splunk import (
- SplunkRequest,
-)
-from ansible_collections.ansible.utils.tests.unit.compat.mock import (
- MagicMock,
- patch,
-)
+from ansible_collections.ansible.utils.tests.unit.compat.mock import MagicMock, patch
+
+from ansible_collections.splunk.es.plugins.action.splunk_data_inputs_monitor import ActionModule
+from ansible_collections.splunk.es.plugins.module_utils.splunk import SplunkRequest
+
RESPONSE_PAYLOAD = {
"entry": [
@@ -66,8 +64,8 @@ RESPONSE_PAYLOAD = {
"whitelist": "//var/log/[0-9]/gm",
},
"name": "/var/log",
- }
- ]
+ },
+ ],
}
REQUEST_PAYLOAD = [
@@ -99,7 +97,7 @@ REQUEST_PAYLOAD = [
class TestSplunkEsDataInputsMonitorRules:
- def setup(self):
+ def setup_method(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
@@ -107,7 +105,7 @@ class TestSplunkEsDataInputsMonitorRules:
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = patch(
- "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection"
+ "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection",
)
connection._socket_path = tempfile.NamedTemporaryFile().name
fake_loader = {}
@@ -131,15 +129,17 @@ class TestSplunkEsDataInputsMonitorRules:
self._plugin.search_for_resource_name.return_value = {}
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return RESPONSE_PAYLOAD
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "merged",
@@ -150,13 +150,15 @@ class TestSplunkEsDataInputsMonitorRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_monitor_merged_idempotent(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return RESPONSE_PAYLOAD
@@ -182,23 +184,25 @@ class TestSplunkEsDataInputsMonitorRules:
"recursive": True,
"sourcetype": "test_source_type",
"whitelist": "//var/log/[0-9]/gm",
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
- assert result["changed"] is False
+ assert result["data_inputs_monitor"]["before"][0]["name"] == "/var/log"
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_monitor_replaced(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = RESPONSE_PAYLOAD
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return RESPONSE_PAYLOAD
@@ -220,7 +224,7 @@ class TestSplunkEsDataInputsMonitorRules:
"index": "default",
"name": "/var/log",
"recursive": True,
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
@@ -228,15 +232,19 @@ class TestSplunkEsDataInputsMonitorRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_monitor_replaced_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return RESPONSE_PAYLOAD
@@ -267,8 +275,8 @@ class TestSplunkEsDataInputsMonitorRules:
"whitelist": "//var/log/[0-9]/gm",
},
"name": "/var/log",
- }
- ]
+ },
+ ],
}
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
@@ -290,7 +298,7 @@ class TestSplunkEsDataInputsMonitorRules:
"recursive": True,
"sourcetype": "test_source_type",
"whitelist": "//var/log/[0-9]/gm",
- }
+ },
],
}
result = self._plugin.run(task_vars=self._task_vars)
@@ -298,13 +306,15 @@ class TestSplunkEsDataInputsMonitorRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_monitor_deleted(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return RESPONSE_PAYLOAD
@@ -326,9 +336,7 @@ class TestSplunkEsDataInputsMonitorRules:
self._plugin.search_for_resource_name = MagicMock()
self._plugin.search_for_resource_name.return_value = {}
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
self._plugin._task.args = {
"state": "deleted",
@@ -339,9 +347,7 @@ class TestSplunkEsDataInputsMonitorRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_monitor_gathered(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def get_by_path(self, path):
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_network.py b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_network.py
index dbadf9052..c76eb1c4f 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_network.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/action/test_es_data_inputs_network.py
@@ -18,27 +18,26 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils.six import PY2
+
builtin_import = "builtins.__import__"
if PY2:
builtin_import = "__builtin__.__import__"
+import copy
import tempfile
+
from ansible.playbook.task import Task
from ansible.template import Templar
-from ansible_collections.splunk.es.plugins.action.splunk_data_inputs_network import (
- ActionModule,
-)
-from ansible_collections.splunk.es.plugins.module_utils.splunk import (
- SplunkRequest,
-)
-from ansible_collections.ansible.utils.tests.unit.compat.mock import (
- MagicMock,
- patch,
-)
+from ansible_collections.ansible.utils.tests.unit.compat.mock import MagicMock, patch
+
+from ansible_collections.splunk.es.plugins.action.splunk_data_inputs_network import ActionModule
+from ansible_collections.splunk.es.plugins.module_utils.splunk import SplunkRequest
+
RESPONSE_PAYLOAD = {
"tcp_cooked": {
@@ -51,7 +50,7 @@ RESPONSE_PAYLOAD = {
"host": "$decideOnStartup",
"restrictToHost": "default",
},
- }
+ },
],
},
"tcp_raw": {
@@ -69,7 +68,7 @@ RESPONSE_PAYLOAD = {
"source": "test_source",
"sourcetype": "test_source_type",
},
- }
+ },
],
},
"udp": {
@@ -88,7 +87,7 @@ RESPONSE_PAYLOAD = {
"source": "test_source",
"sourcetype": "test_source_type",
},
- }
+ },
],
},
"splunktcptoken": {
@@ -98,7 +97,7 @@ RESPONSE_PAYLOAD = {
"content": {
"token": "01234567-0123-0123-0123-012345678901",
},
- }
+ },
],
},
"ssl": {
@@ -106,7 +105,7 @@ RESPONSE_PAYLOAD = {
{
"name": "test_host",
"content": {},
- }
+ },
],
},
}
@@ -173,7 +172,7 @@ REPLACED_RESPONSE_PAYLOAD = {
"host": "$decideOnStartup",
"restrictToHost": "default",
},
- }
+ },
],
},
"tcp_raw": {
@@ -191,7 +190,7 @@ REPLACED_RESPONSE_PAYLOAD = {
"source": "test_source",
"sourcetype": "test_source_type",
},
- }
+ },
],
},
"udp": {
@@ -210,7 +209,7 @@ REPLACED_RESPONSE_PAYLOAD = {
"source": "test_source",
"sourcetype": "test_source_type",
},
- }
+ },
],
},
"splunktcptoken": {
@@ -220,7 +219,7 @@ REPLACED_RESPONSE_PAYLOAD = {
"content": {
"token": "01234567-0123-0123-0123-012345678900",
},
- }
+ },
],
},
}
@@ -273,7 +272,7 @@ REPLACED_REQUEST_PAYLOAD = {
class TestSplunkEsDataInputsNetworksRules:
- def setup(self):
+ def setup_method(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
@@ -281,7 +280,7 @@ class TestSplunkEsDataInputsNetworksRules:
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = patch(
- "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection"
+ "ansible_collections.splunk.es.plugins.module_utils.splunk.Connection",
)
connection._socket_path = tempfile.NamedTemporaryFile().name
fake_loader = {}
@@ -300,19 +299,19 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_merged(self, connection, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
-
# patch update operation
- update_response = RESPONSE_PAYLOAD["tcp_cooked"]
def get_by_path(self, path):
return {}
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return update_response
@@ -320,7 +319,7 @@ class TestSplunkEsDataInputsNetworksRules:
monkeypatch.setattr(SplunkRequest, "create_update", create_update)
# tcp_cooked
- update_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ update_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["tcp_cooked"]],
@@ -329,7 +328,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# tcp_raw
- update_response = RESPONSE_PAYLOAD["tcp_raw"]
+ update_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["tcp_raw"]],
@@ -338,7 +337,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# udp
- update_response = RESPONSE_PAYLOAD["udp"]
+ update_response = copy.deepcopy(RESPONSE_PAYLOAD["udp"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["udp"]],
@@ -347,7 +346,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# splunktcptoken
- update_response = RESPONSE_PAYLOAD["splunktcptoken"]
+ update_response = copy.deepcopy(RESPONSE_PAYLOAD["splunktcptoken"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["splunktcptoken"]],
@@ -356,7 +355,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# ssl
- update_response = RESPONSE_PAYLOAD["ssl"]
+ update_response = copy.deepcopy(RESPONSE_PAYLOAD["ssl"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["ssl"]],
@@ -366,21 +365,27 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_merged_idempotent(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
# patch get operation
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
-
def get_by_path(self, path):
return get_response
+ def create_update(
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
+ ):
+ return get_response
+
monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
+ monkeypatch.setattr(SplunkRequest, "create_update", create_update)
# tcp_cooked
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["tcp_cooked"]],
@@ -389,7 +394,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# tcp_raw
- get_response = RESPONSE_PAYLOAD["tcp_raw"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["tcp_raw"]],
@@ -398,16 +403,15 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# udp
- get_response = RESPONSE_PAYLOAD["udp"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["udp"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["udp"]],
}
- result = self._plugin.run(task_vars=self._task_vars)
assert result["changed"] is False
# splunktcptoken
- get_response = RESPONSE_PAYLOAD["splunktcptoken"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["splunktcptoken"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["splunktcptoken"]],
@@ -416,7 +420,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# ssl
- get_response = RESPONSE_PAYLOAD["ssl"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["ssl"])
self._plugin._task.args = {
"state": "merged",
"config": [REQUEST_PAYLOAD["ssl"]],
@@ -426,25 +430,27 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_replaced(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
# patch get operation
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
- # patch update operation
update_response = REPLACED_RESPONSE_PAYLOAD["tcp_cooked"]
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
-
def delete_by_path(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return {}
def create_update(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return update_response
@@ -456,8 +462,8 @@ class TestSplunkEsDataInputsNetworksRules:
monkeypatch.setattr(SplunkRequest, "delete_by_path", delete_by_path)
# tcp_cooked
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
- update_response = REPLACED_RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
+ update_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["tcp_cooked"]],
@@ -466,8 +472,8 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# tcp_raw
- get_response = RESPONSE_PAYLOAD["tcp_raw"]
- update_response = REPLACED_RESPONSE_PAYLOAD["tcp_raw"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_raw"])
+ update_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["tcp_raw"]],
@@ -476,8 +482,8 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# udp
- get_response = RESPONSE_PAYLOAD["udp"]
- update_response = REPLACED_RESPONSE_PAYLOAD["udp"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["udp"])
+ update_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["udp"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["udp"]],
@@ -486,8 +492,8 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# splunktcptoken
- get_response = RESPONSE_PAYLOAD["splunktcptoken"]
- update_response = REPLACED_RESPONSE_PAYLOAD["splunktcptoken"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["splunktcptoken"])
+ update_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["splunktcptoken"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["splunktcptoken"]],
@@ -497,23 +503,41 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_replaced_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
-
# patch get operation
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
def get_by_path(self, path):
return get_response
+ def delete_by_path(
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
+ ):
+ return {}
+
+ def create_update(
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
+ ):
+ return get_response
+
monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
+ monkeypatch.setattr(SplunkRequest, "delete_by_path", delete_by_path)
+ monkeypatch.setattr(SplunkRequest, "create_update", create_update)
# tcp_cooked
- get_response = REPLACED_RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["tcp_cooked"]],
@@ -522,7 +546,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# tcp_raw
- get_response = REPLACED_RESPONSE_PAYLOAD["tcp_raw"]
+ get_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["tcp_raw"]],
@@ -531,7 +555,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# udp
- get_response = REPLACED_RESPONSE_PAYLOAD["udp"]
+ get_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["udp"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["udp"]],
@@ -540,7 +564,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# splunktcptoken
- get_response = REPLACED_RESPONSE_PAYLOAD["splunktcptoken"]
+ get_response = copy.deepcopy(REPLACED_RESPONSE_PAYLOAD["splunktcptoken"])
self._plugin._task.args = {
"state": "replaced",
"config": [REPLACED_REQUEST_PAYLOAD["splunktcptoken"]],
@@ -550,17 +574,19 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_deleted(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def delete_by_path(
- self, rest_path, data=None, mock=None, mock_data=None
+ self,
+ rest_path,
+ data=None,
+ mock=None,
+ mock_data=None,
):
return {}
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
def get_by_path(self, path):
return get_response
@@ -569,7 +595,7 @@ class TestSplunkEsDataInputsNetworksRules:
monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
# tcp_cooked
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "deleted",
"config": [REQUEST_PAYLOAD["tcp_cooked"]],
@@ -578,7 +604,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is True
# tcp_raw
- get_response = RESPONSE_PAYLOAD["tcp_raw"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "deleted",
"config": [REQUEST_PAYLOAD["tcp_raw"]],
@@ -606,11 +632,11 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_deleted_idempotent(
- self, conn, monkeypatch
+ self,
+ conn,
+ monkeypatch,
):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
def get_by_path(self, path):
@@ -652,13 +678,11 @@ class TestSplunkEsDataInputsNetworksRules:
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_es_data_inputs_network_gathered(self, conn, monkeypatch):
- self._plugin._connection.socket_path = (
- tempfile.NamedTemporaryFile().name
- )
+ self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._connection._shell = MagicMock()
# patch get operation
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
def get_by_path(self, path):
return get_response
@@ -666,7 +690,7 @@ class TestSplunkEsDataInputsNetworksRules:
monkeypatch.setattr(SplunkRequest, "get_by_path", get_by_path)
# tcp_cooked
- get_response = RESPONSE_PAYLOAD["tcp_cooked"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_cooked"])
self._plugin._task.args = {
"state": "gathered",
"config": [REQUEST_PAYLOAD["tcp_cooked"]],
@@ -675,7 +699,7 @@ class TestSplunkEsDataInputsNetworksRules:
assert result["changed"] is False
# tcp_raw
- get_response = RESPONSE_PAYLOAD["tcp_raw"]
+ get_response = copy.deepcopy(RESPONSE_PAYLOAD["tcp_raw"])
self._plugin._task.args = {
"state": "gathered",
"config": [REQUEST_PAYLOAD["tcp_raw"]],
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/modules/conftest.py b/ansible_collections/splunk/es/tests/unit/plugins/modules/conftest.py
index e19a1e04c..349e71ada 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/modules/conftest.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/modules/conftest.py
@@ -2,15 +2,16 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
import pytest
-from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import string_types
@pytest.fixture
@@ -21,20 +22,13 @@ def patch_ansible_module(request, mocker):
if "ANSIBLE_MODULE_ARGS" not in request.param:
request.param = {"ANSIBLE_MODULE_ARGS": request.param}
if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]:
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_remote_tmp"
- ] = "/tmp"
- if (
- "_ansible_keep_remote_files"
- not in request.param["ANSIBLE_MODULE_ARGS"]
- ):
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_keep_remote_files"
- ] = False
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_remote_tmp"] = "/tmp"
+ if "_ansible_keep_remote_files" not in request.param["ANSIBLE_MODULE_ARGS"]:
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_keep_remote_files"] = False
args = json.dumps(request.param)
else:
raise Exception(
- "Malformed data to the patch_ansible_module pytest fixture"
+ "Malformed data to the patch_ansible_module pytest fixture",
)
mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args))
diff --git a/ansible_collections/splunk/es/tests/unit/plugins/modules/utils.py b/ansible_collections/splunk/es/tests/unit/plugins/modules/utils.py
index d55afc0b3..923594463 100644
--- a/ansible_collections/splunk/es/tests/unit/plugins/modules/utils.py
+++ b/ansible_collections/splunk/es/tests/unit/plugins/modules/utils.py
@@ -1,13 +1,15 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
-from ansible_collections.trendmicro.deepsec.tests.unit.compat import unittest
-from ansible_collections.trendmicro.deepsec.tests.unit.compat.mock import patch
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
+from ansible_collections.splunk.es.tests.unit.compat import unittest
+from ansible_collections.splunk.es.tests.unit.compat.mock import patch
+
def set_module_args(args):
if "_ansible_remote_tmp" not in args:
@@ -41,7 +43,9 @@ def fail_json(*args, **kwargs):
class ModuleTestCase(unittest.TestCase):
def setUp(self):
self.mock_module = patch.multiple(
- basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json
+ basic.AnsibleModule,
+ exit_json=exit_json,
+ fail_json=fail_json,
)
self.mock_module.start()
self.mock_sleep = patch("time.sleep")