Skip to content

expanding on credential usage docs #505

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

Merged
merged 3 commits into from
Nov 14, 2019

Conversation

filmaj
Copy link
Contributor

@filmaj filmaj commented Nov 12, 2019

Description

Expanding on the usage section in the Credentials docs. When trying to set up my project for use with MFTF Credentials the first time, I kept getting errors around the key not being found.

Turns out I was following the docs too explicitly. In the usage section, there is no mention of providing the vendor prefix in the key name, whereas in the section on how to add secrets (at least to File Storage), the instructions indicate to prefix your key names with a vendor prefix.

This PR, then, calls out how to use credentials and makes it explicit to, in the File Storage case, prefix your key name with the vendor.

Also tried to be explicit about different usage in File vs Vault Storage configurations, but, I have no experience with Vault Storage, so am assuming a lot about how to use it! This PR could definitely use a once-over with someone who has hands-on experience with using Vault Storage credentials.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

…credentials differently in File vs Vault Storage configurations.
@filmaj filmaj requested a review from dobooth November 12, 2019 21:44
@dobooth dobooth self-assigned this Nov 12, 2019
@dobooth dobooth added the DOC label Nov 12, 2019
@coveralls
Copy link

coveralls commented Nov 12, 2019

Coverage Status

Coverage decreased (-0.04%) to 52.793% when pulling 6dd9655 on filmaj:credential-usage-docs into 3d46fc7 on magento:develop.

@dobooth dobooth requested a review from KevinBKozan November 12, 2019 22:03
lbajsarowicz
lbajsarowicz previously approved these changes Nov 13, 2019
Copy link
Contributor

@lbajsarowicz lbajsarowicz left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Copy link
Contributor

@KevinBKozan KevinBKozan left a comment

Choose a reason for hiding this comment

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

Thank you very much for the PR! I left a comment, tests should actually not use different notation for _CREDS so that you can just use local creds as an override.

I understand that the reason you made this was because there was clearly some lack in clarity in how to set up/use vault, if you think that the .env portion needs to be more front and center then I'd suggest making that this PR's contents.


```xml
<fillField stepKey="FillApiToken" selector=".api-token" userInput="{{_CREDS.my_data_key}}" />
<fillField stepKey="FillApiToken" selector=".api-token" userInput="{{_CREDS.secret/mftf/vendor/my_data_key}}" />
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually incorrect, you need to be able to just use vendor/my_data_key for both (MFTF checks file storage, then vault).

If you're having issues with getting MFTF to read the vault version, see this section of devdocs:
https://devdocs.magento.com/mftf/docs/credentials.html#setup-mftf-to-use-vault

I think you just need to set this in .env:
CREDENTIAL_VAULT_SECRET_BASE_PATH=secret
MFTF should automatically call <CREDENTIAL_VAULT_ADDRESS>/<CREDENTIAL_VAULT_SECRET_BASE_PATH>/mftf/<vendor/my_data_key> in your case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @KevinBKozan ! I actually do not have Vault set up locally, so I was completely shooting in the dark with the Vault portion of the docs.

Do you have suggestions on how to modify this section? Ideally, I would imagine the best developer experience here would be to use the same token to access the secret regardless of the underlying storage leveraged. If that is the case, then I can definitely simplify the wording in the docs here to make that clear! Just let me know.

Copy link
Contributor

@KevinBKozan KevinBKozan Nov 13, 2019

Choose a reason for hiding this comment

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

Gotcha. I think some background info is kind of necessary to be able to make good changes to the docs, but the tl;dr is Vault integration with MFTF is about 50% done in the whole picture (framework integration is complete, build/EQP integration is not).

The primary purpose of the vault integration is actually to connect to the (as of yet, non-existant) MFTF vault credential store. This is the thing that builds are going to be using to run tests, so it becomes the "canonical" list of credentials that if you submit an extension, you can submit creds to your sandbox or testing environment.

So with that said, for local test running the prefered way would actually be for you to just define creds in .credentials as you need them. If you're running a test that requires _CREDS.some_api_key it'd be then on you to define it in .credentials since you would conceivably know the value (if you have access to it).

You can still use vault to resolve these _CREDS references though. So say a test is using _CREDS.some_api_key, the user flow would have to be

  • brew install vault
  • vault login <username/token/whatever EQP decides to use>
    • vault is now authenticated on the machine, MFTF will use this auth to access creds
    • you don't need to tell vault where the server is AFAIK, it will know by your token to map it to the right server
  • define details in .env:
    • CREDENTIAL_VAULT_ADDRESS=<whatever it ends up being>
    • CREDENTIAL_VAULT_SECRET_BASE_PATH=<probably just "secret">
    • MFTF now knows what the vault address is, what the base path is, and has auth to access it

Copy link
Contributor

@KevinBKozan KevinBKozan Nov 13, 2019

Choose a reason for hiding this comment

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

So I guess the followup question is, what are you trying to use vault for, connecting to that central service or a local instance? That may help guide how we can make this document better to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I'm using File Storage (.credentials file) locally so the updated File Storage docs is all I would add. I assumed Vault Storage was ready; if it's not, perhaps best to leave out any details for now. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're honestly probably right. We can make reasonable assumptions about how it all ends up being implemented outside MFTF (as a framework), but we can leave out details for now. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I've updated the docs to remove the Vault details.

@KevinBKozan KevinBKozan merged commit 6c13d9d into magento:develop Nov 14, 2019
@KevinBKozan
Copy link
Contributor

@filmaj thank you for the contribution + discussion! We'll keep you all updated as the vault implementations get further along 👍

@filmaj filmaj deleted the credential-usage-docs branch November 14, 2019 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants