delphix / virtualization-sdk

Delphix vSDK.
Apache License 2.0
7 stars 25 forks source link

"[March 05, 2022] [BUG] retrieve_credentials() returns incorrect KeyPairCredentials object if credential_supplier has empty password" #427

Closed Balamuruhan closed 2 years ago

Balamuruhan commented 2 years ago

Expected Behavior Even if credentials_supplier dict has empty password is should return PasswordCredentials() object but instead KeyPairCredentials() is returned.

Actual Behavior For EBS plugin implemented in vsdk, we use passwordCredentialsSupplier for System Password field which is retrieved from UI and used in our workflows. But this field is optional field, where user may not provide it in most of the cases. So when we upgrade the plugin from Lua to VSDK and empty password is passed in for System password field. After upgrade, when VSDK code retrieves it using retrieve_credentials() fails with AttributeError as retrieve_credentials() returns the KeyPairCredentials() instead of PasswordCredentials(). This is because there is a check credentials_result.password != "" which is incorrect, instead it should be "password" in credentials_supplier

Steps To Reproduce the Problem Call the retrieve_credentials() with dict {'password': '', 'type': 'NamedPasswordCredential'},

from dlpx.virtualization import libs
vault = {'password': '', 'type': 'NamedPasswordCredential'}
password = libs.retrieve_credentials(vault).password # We hit AttributeError as it returns KeyPairCredentials object which doesn't have attribute password.

Steps to reproduce the behavior:

  1. Use EBS Lua plugin to link and provision datasets with System Password field empty
  2. Disable datasets.
  3. Upgrade Lua to VSDK plugin
  4. Refresh the environments
  5. Enable datasets after successful upgrade.
  6. We hit AttributeError when dataset starts to run on vsdk plugin due to this issue