Repository navigation
Make Test Suite Self-Contained Without AWS Credentials or External Secrets - #213
Conversation
| # Test-only RSA keypair for JWT encode/decode in specs. | ||
| # Not used in any deployed environment. | ||
| # rubocop:disable Layout/LineLength -- PEM blocks | ||
| ENV["JWT_PRIVATE_KEY"] = <<~PEM |
There was a problem hiding this comment.
I don't think we should ever embed in our public repositories private/public key pairs, even if this is only ever used for the tests, it exposes a key that while currently won't be used in production, things can change and we could accidentally expose details we don't expect to.
Using github secrets is a better alternative because it's never then exposed. An alternative to this might instead be to just generate a key pair dynamically in the code.
There was a problem hiding this comment.
While I don't 100% agree when these keys are kept in specs and not reused elsewhere, I think it is also fine to generate the pair dynamically. I don't think they should have to be kept in the environment whether that is provided in the github secrets or elsewhere.
I'll work on generating them dynamically
There was a problem hiding this comment.
Looks like we have gone through iterations on this idea before in other projects
datacite/lupo@c5c3c61
Lupo currently uses fixtures for keys.
There was a problem hiding this comment.
Thanks for taking a look at this @richardhallett . I've updated the helper so that it generates the public private pair once per Rspec process.
There was a problem hiding this comment.
There are a couple of lines printed when the specs run; JWT decode ERROR lines that are the expected empty/abc token cases
Purpose
Make the test suite self-contained and remove its dependency on AWS credentials and deployed-environment secrets.
Approach
Configure tests to use local filesystem storage, provide dedicated test JWT keys, stub AWS SDK responses, and clean up generated report files after the test suite completes.
Key Modifications
tmp/report_files.warn.Important Technical Details
tmp/report_filesand removed after the suite completes..envvalues from affecting tests.Types of changes
Reviewer, please remember our guidelines: