-
Notifications
You must be signed in to change notification settings - Fork 83
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
grafana_folder: add permissions #231
base: main
Are you sure you want to change the base?
Changes from all commits
f410d3c
5de9896
2c6fc2e
d52a99f
8a12b5f
d4af773
d4349c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,93 @@ | |
- "result.changed == false" | ||
- "result.folder.title == 'grafana_working_group'" | ||
|
||
|
||
- name: Change folder permissions | ||
grafana_folder: | ||
url: "{{ grafana_url }}" | ||
url_username: "{{ grafana_username }}" | ||
url_password: "{{ grafana_password }}" | ||
title: "grafana_working_group" | ||
state: present | ||
permissions: | ||
- role: "Editor" | ||
permission: "admin" | ||
- role: "Viewer" | ||
permission: "view" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "result.folder.title == 'grafana_working_group'" | ||
|
||
rrey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Test folder permission idempotency | ||
grafana_folder: | ||
url: "{{ grafana_url }}" | ||
url_username: "{{ grafana_username }}" | ||
url_password: "{{ grafana_password }}" | ||
title: "grafana_working_group" | ||
state: present | ||
permissions: | ||
- role: "Editor" | ||
permission: "admin" | ||
- role: "Viewer" | ||
permission: "view" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
- "result.folder.title == 'grafana_working_group'" | ||
|
||
- name: Test folder permission user lookup | ||
grafana_folder: | ||
url: "{{ grafana_url }}" | ||
url_username: "{{ grafana_username }}" | ||
url_password: "{{ grafana_password }}" | ||
title: "grafana_working_group" | ||
state: present | ||
permissions: | ||
- role: "Editor" | ||
permission: "admin" | ||
- role: "Viewer" | ||
permission: "view" | ||
- username: "unknown" | ||
permission: "edit" | ||
register: result | ||
ignore_errors: true | ||
|
||
- set_fact: | ||
expected_error: "User 'unknown' does not exists" | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
- "result.failed == true" | ||
- "result.msg == expected_error" | ||
|
||
- name: Test folder permission team lookup | ||
grafana_folder: | ||
url: "{{ grafana_url }}" | ||
url_username: "{{ grafana_username }}" | ||
url_password: "{{ grafana_password }}" | ||
title: "grafana_working_group" | ||
state: present | ||
permissions: | ||
- team: "unknown" | ||
permission: "edit" | ||
register: result | ||
ignore_errors: true | ||
|
||
- set_fact: | ||
expected_error: "Team 'unknown' does not exists" | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
- "result.failed == true" | ||
- "result.msg == expected_error" | ||
Comment on lines
+112
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CWollinger I don't know if you still want to finish this PR but I am realizing now after coming back to this PR that we don't check the permissions in these tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will check this. |
||
|
||
- name: Delete a Folder | ||
grafana_folder: | ||
url: "{{ grafana_url }}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have code in
grafana_team.py
doing this (line 241).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we export these functions to module_utils and import this from both modules? Could be also interesting for other functions like
community.grafana/plugins/modules/grafana_team.py
Line 226 in 108b8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that is something I'd like to do at some point ; have all Grafana API call related stuff in module_utils and have our library that we can use in all modules.
I guess it will be easier if you move the team related stuff that you need to have the big change that I will never have time to review properly.
Sorry for the delay on this PR.