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

tests(parameters): integration tests for SecretsProvider #1263

Merged
merged 6 commits into from
Feb 7, 2023
Merged

tests(parameters): integration tests for SecretsProvider #1263

merged 6 commits into from
Feb 7, 2023

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Jan 28, 2023

Description of your changes

As part of #1039 , we need to implement integration tests for the SecretsProvider which is part of the upcoming Parameters utility.

The test cases cover string, json, binary and auto transformer. We don't cover the cases for sdk client options and I will add them after #1222 is resolved.

Related issues, RFCs

Issue number: #1241

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Jan 28, 2023
@am29d
Copy link
Contributor Author

am29d commented Jan 30, 2023

Should I keep it as a draft until we merge #1260 for all types?

Copy link
Contributor

@dreamorosi dreamorosi 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 for the PR, appreciate it!

Left a couple of minor comments to understand the function code.

Happy to merge this once review is ready, no need to wait for other PRs.

Whenever you have time, could you please leave a comment under the linked issue so that I can assign it to you?

import { Context } from 'aws-lambda';
import { SecretsProvider } from '../../lib/secrets';
import { TinyLogger } from '../helpers/tinyLogger';
import { transform } from 'esbuild';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we import this and use it in the conditional? Not challenging, just asking because I'm not clear on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not make any sense 🤔 , it should be options in the conditional. Will change that.

const secretNameObjectWithSuffix = process.env.SECRET_NAME_OBJECT_WITH_SUFFIX || '';
const secretNameBinaryWithSuffix = process.env.SECRET_NAME_BINARY_WITH_SUFFIX || '';

const _call_get = async (paramName: string, testName: string, options?: SecretsGetOptionsInterface) : Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this work once we introduce multiple providers (i.e. once #1222 is merged and we need multiple SecretsProviders)? Should we add a new parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, lets pass the provider in the signature. Should we wait until #1222 is merged, or can I change it now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do it now, so later we can just add a new block at the end of the main handler

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey guys! #1222 is ready for review.

@am29d am29d requested a review from dreamorosi February 6, 2023 13:42
@dreamorosi
Copy link
Contributor

Hi @am29d I have merged #1222 earlier today, so the tests that involve caching and/or passing a custom AWS SDK client can now be worked on.

Do you prefer adding them to this PR, or should we open a separate issue to address them in a future PR?

I'm okay either way.

@dreamorosi dreamorosi linked an issue Feb 7, 2023 that may be closed by this pull request
2 tasks
@dreamorosi dreamorosi added parameters This item relates to the Parameters Utility tests PRs that add or change tests labels Feb 7, 2023
@am29d
Copy link
Contributor Author

am29d commented Feb 7, 2023

I added two test cases, one for caching and other for force fetch. I am not sure what other cases with custom SDK client we should cover with e2e tests. The major benefit comes from injecting clients for testing, which is not something we should assess with e2e.

What do you think?

@dreamorosi
Copy link
Contributor

What do you think?

Completely agree, the fact that we can check the caching already proves the injection works correctly. I'm okay with the current test surface for now.

@dreamorosi
Copy link
Contributor

I have ran the integration tests locally after checking out your branch and they are passing:

Screenshot 2023-02-07 at 17 06 43

@dreamorosi
Copy link
Contributor

Thank you for the work on this Alex, really appreciate it!

@dreamorosi dreamorosi merged commit de02b3d into aws-powertools:main Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parameters This item relates to the Parameters Utility size/L PRs between 100-499 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: integration tests for SecretsProvider
3 participants