Skip to content

Commit

Permalink
event_stream - Ensure forward_events works as expected (#337)
Browse files Browse the repository at this point in the history
* Rename forward_events to test_mode to be consistent with the API

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Re-work

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Ensure default value aligns with the API

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

---------

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
Co-authored-by: Alex <aizquier@redhat.com>
  • Loading branch information
alinabuzachis and Alex-Izquierdo authored Oct 9, 2024
1 parent 0224374 commit 94d1e12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions plugins/modules/event_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
description:
- Enable the event stream to forward events to the rulebook activation where it is configured.
type: bool
default: True
default: false
version_added: 2.1.0
state:
description:
Expand Down Expand Up @@ -118,7 +118,10 @@ def create_params(module: AnsibleModule, controller: Controller) -> dict[str, An
credential_params["event_stream_type"] = module.params["event_stream_type"]

if module.params.get("forward_events") is not None:
credential_params["test_mode"] = module.params["forward_events"]
if module.params["forward_events"]:
credential_params["test_mode"] = False
else:
credential_params["test_mode"] = True

if module.params.get("headers"):
credential_params["additional_data_headers"] = module.params["headers"]
Expand Down Expand Up @@ -156,7 +159,7 @@ def main() -> None:
organization_name=dict(type="str", aliases=["organization"]),
event_stream_type=dict(type="str", aliases=["type"]),
headers=dict(type="str", default=""),
forward_events=dict(type="bool", default=True),
forward_events=dict(type="bool", default=False),
state=dict(choices=["present", "absent"], default="present"),
)

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/event_stream/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
name: "{{ event_stream_name }}"
credential_name: "{{ credential_name }}"
organization_name: Default
forward_events: False
event_stream_type: Basic Event Stream
forward_events: false
event_stream_type: "basic"
check_mode: true
register: _result

Expand Down Expand Up @@ -141,7 +141,7 @@
organization_name: Default
event_stream_type: "basic"
headers: "Authorization,Custom-Header"
forward_events: False
forward_events: true
register: _result

- name: Check event stream is updated
Expand All @@ -154,7 +154,7 @@
name: "{{ new_event_stream_name }}"
register: _result

- name: Check if event stream headers and forward_events are updated
- name: Check if event stream headers and test_mode are updated
assert:
that:
- _result.event_streams[0].name == new_event_stream_name
Expand Down

0 comments on commit 94d1e12

Please sign in to comment.