Open ArturT opened 3 years ago
Here are some tips on how to implement this feature. It might be helpful if someone would like to help us develop this feature.
First, it's good to understand how Queue Mode works in Knapsack Pro. https://docs.knapsackpro.com/2020/how-to-speed-up-ruby-and-javascript-tests-with-ci-parallelisation
Then it's good to understand the general architecture of @knapsack-pro/core
library and how other clients for Jest (@knapsack-pro/jest
) or Cypress (@knapsack-pro/cypress
) uses it. This article explains it:
https://docs.knapsackpro.com/2020/how-to-build-native-integration-with-knapsack-pro-api-to-run-tests-in-parallel-for-any-test-runner-testing-framework
You can setup @knapsack-pro/core
in development https://github.com/KnapsackPro/knapsack-pro-core-js#development
You can setup @knapsack-pro/jest
in development https://github.com/KnapsackPro/knapsack-pro-jest#development
You can setup jest-example-test-suite
project in development https://github.com/KnapsackPro/jest-example-test-suite
@knapsack-pro/core
or @knapsack-pro/jest
you can run the script bin/knapsack_pro_jest
. The script connects with Knapsack Pro Staging API. Sometimes you need to run it twice to get our staging API up and running (the staging API can get turn off when no requests to it).bin/knapsack_pro_jest_encryption
to test the encryption feature :)Here are a few tips on what places in code @knapsack-pro/core
would need to have encryption and decryption added.
Encryption:
allTestFiles
should be encrypted before we send a list of test files existing on the disk to the API. We could do something like knapsackProCipher.encryptArray(allTestFiles)
. It would be good to have a separate service/class like KnapsackProCipher
which does encrypt/decrypt string to separate encryption logic from API logic.
branch
should be encrypted before sending to API
Decryption:
queueTestFiles
will be an encrypted list of test files returned by Knapsack Pro API. You should decrypt it. You could call service/class to decrypt it const queueTestFiles = knapsackProCipher.decryptArray(response.data.test_files);
https://github.com/KnapsackPro/knapsack-pro-core-js/blob/0f44c6a3daa369cd4353e315abbf5539295289ea/src/knapsack-pro-core.ts#L58It's up to you if encrypt/decrypt function takes array or string. Feel free to figure out what would be a good enough way:
knapsackProCipher.decryptArray(response.data.test_files)
knapsackProCipher.decrypt(test_file)
and you would need to run map on response.data.test_files
to decrypt each string.If you would like to help us with this feature feel free to do it. I can answer any questions and help later one with the documentation, code review, and final testing and releasing new versions of all libraries like @knapsack-pro/core
, @knapsack-pro/jest
, @knapsack-pro/cypress
.
Please add me rights to push to your PR code so I can help :)
about the feature
Allow user to enable encryption of sensitive data like:
why we need this feature?
Some of the customers requested encryption for Jest.
idea how to implement it
Let's keep it simple.
Here is some info about the existing encryption feature for Ruby which might be too complex. We could do it simpler for Knapsack Pro in JavaScript (feature should be implemented in
@knapsack-pro/core
npm package so other packages like@knapsack-pro/jest
or@knapsack-pro/cypress
could use it).In knapsack_pro ruby gem there is an encryption feature but it is a bit overcomplicated. It allows encrypting separately test file paths and branch names. It does not allow decryption so that's a downside for the development and performance of some of the features like RSpec split by examples because there is no simple way to decrypt test files on CI without encrypting all test files first to get SHA2 key (SHA2 value is used to compare SHA2 values from API response to identify test file paths).
In case of
@knapsack-pro/core
library I would recommend:KNAPSACK_PRO_ENCRYPTION_KEY
has value then it could mean encryption is enabled and the key will be used to encrypt and decrypt string like test file path & branch names.story
https://trello.com/c/f494kFmB