Skip to content

Commit

Permalink
Fix lint errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyrZotov committed Nov 20, 2023
1 parent 78b0ae8 commit 31652f4
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 104 deletions.
24 changes: 8 additions & 16 deletions changelogs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@ prelude_section_name: release_summary
prelude_section_title: Release Summary
sanitize_changelog: true
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
- ['major_changes', 'Major Changes']
- ['minor_changes', 'Minor Changes']
- ['breaking_changes', 'Breaking Changes / Porting Guide']
- ['deprecated_features', 'Deprecated Features']
- ['removed_features', 'Removed Features (previously deprecated)']
- ['security_fixes', 'Security Fixes']
- ['bugfixes', 'Bugfixes']
- ['known_issues', 'Known Issues']
title: onepassword.connect
trivial_section_name: trivial
use_fqcn: true
28 changes: 14 additions & 14 deletions plugins/modules/generic_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@
field_type: concealed
generate_value: on_create
generator_recipe:
length: 16
include_letters: yes
include_digits: yes
include_symbols: no
length: 16
include_letters: true
include_digits: true
include_symbols: false
section: Club Card Details
register: op_item # Access item values through `op_item['data']`
no_log: true # Hide the output - it will contain the secret value you just stored
Expand All @@ -212,13 +212,13 @@
fields:
- label: Secret Code
field_type: concealed
overwrite: no
overwrite: false
generate_value: never
generator_recipe: # ignored because generate_value == never
length: 16
include_letters: yes
include_digits: yes
include_symbols: no
length: 16
include_letters: true
include_digits: true
include_symbols: false
section: Club Card Details
no_log: true
Expand All @@ -230,13 +230,13 @@
fields:
- label: Secret Code
field_type: concealed
overwrite: no
overwrite: false
generate_value: on_create
generator_recipe: # ignored because generate_value == never
length: 16
include_letters: yes
include_digits: yes
include_symbols: no
length: 16
include_letters: true
include_digits: true
include_symbols: false
section: Club Card Details
no_log: true
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/targets/field_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# and should not be used as examples of how to write Ansible roles #
####################################################################
---
- import_tasks: tests.yml
- name: Field Info task
ansible.builtin.import_tasks: tests.yml
environment:
OP_CONNECT_HOST: "__OP_CONNECT_HOST__"
OP_CONNECT_TOKEN: "__OP_CONNECT_TOKEN__"
Expand Down
56 changes: 28 additions & 28 deletions tests/integration/targets/field_info/tasks/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

- set_fact:
- name: Set Fact
ansible.builtin.set_fact:
field_label_to_find: "frogs frogs frogs"
item_title: "Test Field Lookup - ANSIBLE {{ 9999 | random }}"
created_item_ids: []
Expand All @@ -27,18 +28,19 @@

register: test_item

- set_fact:
- name: Set Fact
ansible.builtin.set_fact:
mysql_section_id: test_item.op_item.sections[0].id

- name: Find Field | Field in item root
field_info:
item: "{{ item_title }}"
field: "{{ field_label_to_find }}"
vault: "{{test_item.op_item.vault.id}}"
vault: "{{ test_item.op_item.vault.id }}"
register: found_root_field

- name: Find Field | Assert root field was found
assert:
ansible.builtin.assert:
that:
- "found_root_field.field.value == test_item.op_item.fields['{{ field_label_to_find }}'].value"
- "found_root_field.field.id == test_item.op_item.fields['{{ field_label_to_find }}'].id"
Expand All @@ -47,28 +49,27 @@
field_info:
item: "{{ test_item.op_item.id }}"
field: "{{ field_label_to_find }}"
vault: "{{test_item.op_item.vault.id}}"
vault: "{{ test_item.op_item.vault.id }}"
register: found_field_by_item_id

- name: Find Field | Assert field was found
assert:
ansible.builtin.assert:
that:
"found_field_by_item_id.field.id == test_item.op_item.fields['{{ field_label_to_find }}'].id"

- block:
- name: Find Field | Search by unknown item label
field_info:
item: "{{ test_item.op_item.id }}"
field: "doesNotExist"
vault: "{{test_item.op_item.vault.id}}"
register: notfound_result
ignore_errors: yes
- name: Find Field | Search by unknown item label
field_info:
item: "{{ test_item.op_item.id }}"
field: "doesNotExist"
vault: "{{ test_item.op_item.vault.id }}"
register: notfound_result
ignore_errors: true

- name: Find Field | Assert field not found returns error
assert:
ansible.builtin.assert:
that:
- notfound_result.failed
- "{{ notfound_result.field|length }} == 0"
- "{{ notfound_result.field | length }} == 0"

- name: Find Field | Search with section label
field_info:
Expand All @@ -79,27 +80,26 @@
register: mysql_field

- name: Find Field by Section | Assert field within MySQL section was found
assert:
ansible.builtin.assert:
that:
- mysql_field.field.value == "penny"
- mysql_field.field.section

- block:
- name: Find Field | Search with section label for undefined field
field_info:
item: "{{ item_title }}"
field: "doesNotExist"
vault: "{{test_item.op_item.vault.id}}"
register: notfound_bysection_result
ignore_errors: yes
- name: Find Field | Search with section label for undefined field
field_info:
item: "{{ item_title }}"
field: "doesNotExist"
vault: "{{ test_item.op_item.vault.id }}"
register: notfound_bysection_result
ignore_errors: true

- name: Find Field | Assert field not found returns error
assert:
ansible.builtin.assert:
that:
- notfound_bysection_result.failed
- "{{ notfound_bysection_result.field|length }} == 0"
- "{{ notfound_bysection_result.field | length }} == 0"

- name: Cleanup | Remove test items
generic_item:
state: absent
uuid: "{{ test_item.op_item.id }}"
uuid: "{{ test_item.op_item.id }}"
3 changes: 2 additions & 1 deletion tests/integration/targets/generic_item/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# and should not be used as examples of how to write Ansible roles #
####################################################################
---
- import_tasks: tests.yml
- name: Generic Item task
ansible.builtin.import_tasks: tests.yml
environment:
OP_CONNECT_HOST: "__OP_CONNECT_HOST__"
OP_CONNECT_TOKEN: "__OP_CONNECT_TOKEN__"
Expand Down
29 changes: 16 additions & 13 deletions tests/integration/targets/generic_item/tasks/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

- set_fact:
- name: Set Facts
ansible.builtin.set_fact:
field_wont_exist_after_update: "transitoryExampleLabel"
original_item_title: "Example Item - ANSIBLE TEST {{ 9999 | random }}"
created_item_ids: []
Expand All @@ -18,7 +19,7 @@
field_type: concealed
generate_value: always
generator_recipe:
include_digits: no
include_digits: false

- label: "{{ field_wont_exist_after_update }}"
value: example
Expand All @@ -34,7 +35,7 @@
# NOTE: Connect server <= 1.2.0 changes name of the field with purpose==PASSWORD
# to `password`
- name: Create Item | Assert expected item properties and fields
assert:
ansible.builtin.assert:
that:
- original.changed
- original.op_item is defined
Expand All @@ -43,8 +44,9 @@
- original.op_item.fields.password is defined
- "original.op_item.fields.password.purpose == 'PASSWORD'"

- set_fact:
created_item_ids: "{{ created_item_ids + [ original.op_item.id ] }}"
- name: Set facts
ansible.builtin.set_fact:
created_item_ids: "{{ created_item_ids + [original.op_item.id] }}"
updated_item_title: "{{ original.op_item.title }} UPDATED"

- name: Upsert item
Expand All @@ -61,15 +63,15 @@
field_type: concealed
generate_value: on_create
generator_recipe:
include_digits: no
include_digits: false

- label: Generated String
generate_value: always
section: "Collaboration Details"
register: updated_1p_item

- name: Upsert item | Assert updated item properties
assert:
ansible.builtin.assert:
that:
- updated_1p_item.changed
- updated_1p_item.op_item.id == original.op_item.id
Expand All @@ -79,7 +81,7 @@
- "updated_1p_item.op_item.fields['Generated String'].value != original.op_item.fields['Generated String'].value"

- name: Upsert item | Assert tags updated
assert:
ansible.builtin.assert:
that:
- "'{{ item }}' in updated_1p_item.op_item.tags"
with_items:
Expand All @@ -99,7 +101,7 @@
field_type: concealed
generate_value: on_create
generator_recipe:
include_digits: no
include_digits: false

- label: Hello
value: "World"
Expand All @@ -110,7 +112,7 @@
register: updated_1p_item_by_name

- name: Update Item by Name | Assert existing fields are preserved
assert:
ansible.builtin.assert:
that:
- "'{{ item }}' in updated_1p_item_by_name.op_item.fields"
- "updated_1p_item_by_name.op_item.fields['{{ item }}'].value == updated_1p_item.op_item.fields['{{ item }}'].value"
Expand All @@ -128,13 +130,14 @@
register: item_with_default_template

- name: Default Template | Default template was used
assert:
ansible.builtin.assert:
that:
- item_with_default_template.changed
- 'item_with_default_template.op_item.category == "API_CREDENTIAL"'

- set_fact:
created_item_ids: "{{ created_item_ids + [ item_with_default_template.op_item.id ] }}"
- name: Set Facts
ansible.builtin.set_fact:
created_item_ids: "{{ created_item_ids + [item_with_default_template.op_item.id] }}"

- name: Cleanup | Remove created items
generic_item:
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/targets/generic_item/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This is a "fake" JWT; its decoded form does not adhere to the Server spec nor does it contain any valid data.
op_api_token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2MDMzMDUyMTgsImV4cCI6MTYzNDg0MTIxOCwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2NrZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.vJ7uaGuJ3Gn1gTgwjs96pUp4YiOjoH9zaSO0dT77uAY"
op_api_token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.\
eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2MDMzMDUyMTgsImV4cCI6MTYzNDg0MTIxOCwiYXVkIjoid3d3LmV4\
YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2Nr\
ZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.\
vJ7uaGuJ3Gn1gTgwjs96pUp4YiOjoH9zaSO0dT77uAY"
op_server_url: http://localhost:8080"
3 changes: 2 additions & 1 deletion tests/integration/targets/item_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# and should not be used as examples of how to write Ansible roles #
####################################################################
---
- import_tasks: tests.yml
- name: Item Info task
ansible.builtin.import_tasks: tests.yml
environment:
OP_CONNECT_HOST: "__OP_CONNECT_HOST__"
OP_CONNECT_TOKEN: "__OP_CONNECT_TOKEN__"
Expand Down
Loading

0 comments on commit 31652f4

Please sign in to comment.