Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a shared vcr spec helper for access to secrets
We need a way to sanitize actual secrets with fake and consistent values so tests are reliable. This mechanism must allow us to provide overide values with real secrets when we're actually recording new or updated cassettes. For now, we're reusing the existing mechanism of specifying the secrets: * relative to the current directory - we run specs for plugins from the plugin's directory * config/secrets.yml - actual secrets * config/secrets.defaults.yml - defaults for sanitizing real values with consistent repeatable replacements Plugins can use this mechanism by adding: Object.include Spec::Shared::CassetteSecretsHelper to their spec_helper.rb. You can then access these values via helper methods with interfaces like below: default_vcr_secret_by_key_path(:vmware_infra, :hostname) vcr_secret_by_key_path(:vmware_tanzu, :hostname) Each plugin should define their own: config/secrets.default.yml, which can look something like this: ``` --- :vmware_cloud: :host: vmwarecloudhost :userid: VMWARE_CLOUD_USERID :password: VMWARE_CLOUD_PASSWORD :vmware_infra: :hostname: HOSTNAME :vmware_tanzu: :hostname: vmware-tanzu-hostname :userid: VMWARE_TANZU_USERID :password: VMWARE_TANZU_PASSWORD ``` Developers can then copy this file to config/secrets.yml and provide actual values for each of the keys. When recording, the cassettes will use the real values for connecting to environments, but store the resulting placeholder using the fake value for that key from the defaults.
- Loading branch information