Skip to content
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

REL-4242 - Python SDK v16.6.2 - Empty fields and no dependency on helper #527

Merged
merged 7 commits into from
Sep 15, 2023

Conversation

maksimu
Copy link
Collaborator

@maksimu maksimu commented Sep 14, 2023

No description provided.

maksimu and others added 2 commits September 14, 2023 16:14
#525)

* fix for record's data JSON where "fields": null 
* added test for clients that do not store "fields":[] or set it to null
jwalstra-keeper and others added 5 commits September 14, 2023 16:29
* KSM-440 Ansible Cache Records

Created a new Ansible action to retrieve records from the Vault and
create a encrypted serialized cache. This cache can then be set on
the attributes of the existing action. If set, the existing actions
will use the records in the cache. However, if the action uses
notation, the cache will not work. The KSM SDK notation method
needs to be changed to allow a list of Record to be passed in. Right
now it always get record from the Keeper Vault.

The new action `keeper_cache_records` takes a list of UID and/or titles.

```yaml
  tasks:
    - name: Generate a Keeper Record Cache secret
      keeper_password:
        length: 64
      register: keeper_record_cache_secret
      no_log: True

    - name: Store the Keeper Record Cache secret into variables.
      set_fact:
        keeper_record_cache_secret: "{{ keeper_record_cache_secret.password }}"
      no_log: True

    - name: Cache records. Will use keeper_record_cache_secret from above.
      keeper_cache_records:
        uids:
          - RECORD UID 1
          - RECORD UID 2
        titles:
          - TITLE 1
          - TITLE 2
      register: my_records
      no_log: True

    - name: "Get Value By UID"
      keeper_get:
        cache: "{{ my_records.cache }}"
        uid: RECORD UID 1
        field: "password"
      register: "my_password_by_uid"
```

Bonus changes

* Added the ability to select records by title to the `keeper_get`, `keeper_set`, and
  `keeper_copy` actions.
* Added a non-notation selectors for complex field values. The attributes
  `array_index` and `value_key` allow selecting which object/value in an array
  and key/value pair for dictionaries.
* Updated the test framework. Changes in Ansible broke our test framework.

* KSM-458 Remove core dep on helper module

Refactor add_custom_field not to use the helper module. The method
will accept an instance of FieldType, however it is not tied to the
keeper_secrets_manager_helper.v3.field_type.FieldType module.

Allow the ability to set the type, label, and value not using the
FieldType instance. The method will still take the param `field`,
however it will also take `field_type`, `label`, and `value`. This
allows adding a custom field without have to use the helper module.

Removed references `keeper-secrets-manager-helper` from setup.py
and requirements.txt. This should break the circular reference.

Added unit tests for the method.

---------

Co-authored-by: Max Ustinov <[email protected]>
* fix for record's data JSON where "fields": null
added test for clients that do not store "fields":[] or set it to null

* auto-format record tests
Adjusted the dump method in Keeper Secrets Manager's mock.py to account for empty _fields variable, preventing a NoneType error. Updated the unit tests in secret_test.py to align with these changes, reducing the expected length of fields from 6 to 4 and adjusting the index of field from 1 to 0. Also, removed unnecessary print statement in the test. This ensures that tests correctly correspond to the application code and avoid false negatives.
Revised the dump method in keeper_secrets_manager_core/mock.py to handle non-list types of self._fields properly. Also modified test commands in secret_test.py, removing '--inflate' and '--deflate' flags to accurately reflect the current functionality. Adjustments in test and core functions are necessary to ensure aligned and accurate testing, and to handle various data types in the dump method.
Changed access index from 0 to 1 while fetching "fields" list in secret_test.py, under the assertion tests. This change is due to adjustments made in the application code where the first element could possibly be None, hence to prevent False negatives and maintaining the relevance of tests, this index shift was necessary.
@maksimu maksimu marked this pull request as ready for review September 15, 2023 21:15
@maksimu maksimu requested a review from saldoukhov as a code owner September 15, 2023 21:15
@maksimu maksimu merged commit 67b1dc4 into master Sep 15, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants