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

Enhance pm.vault API with improved get and set methods #1059

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

saksham-postman
Copy link

This PR modifies the pm.vault API to enhance its functionality and improve type safety.

The main changes are:

  1. Modified get method:
  • Now returns undefined instead of null when a key is not found
  • Improves consistency with JavaScript's behavior for non-existent object properties
  1. Modified set method:
  • Now returns the value that was set
  • Allows for easier chaining and verification of set operations
  1. Updated type definitions:
  • set method now returns Promise instead of Promise
  1. Added new tests:
  • Verify that all vault operations return promises
  • Ensure pm.vault is not accessible when vaultSecrets is not set

@@ -33,11 +33,11 @@ class Vault {
const getVaultInterface = (vault) => {
return {
get: (key) => {
return vault('get', key);
return vault('get', key).then((value) => { return (value === null ? undefined : value); });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this coming null in the first place? This looks like a patch rather than fixing the root cause

},

set: (key, value) => {
return vault('set', key, value);
return vault('set', key, value).then(() => { return value; });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making this change?

.set returns undefined for other variable scopes.

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.

2 participants