Skip to content

event_stream - Ensure forward_events works as expected #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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