-
Notifications
You must be signed in to change notification settings - Fork 4
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
Switch from using the global agent to using global keypairs for tests #404
Comments
I'm going to change this up slightly and include it in MatrixAI/Polykey-CLI#10, #391. Instead of using mocking for this I'll add a parameter/ENV for setting the root private key to skip the generation step. We can extend this change to key mocking across all tests. That should be a separate issue however. The changes here should be
I also need to create a new issue to replace key mocking for all tests. |
…erride` parameter for `createKeyManager` This will skip key generation and use the provided `PrivateKey` instead. This should speed up testing by skipping the key generation. Related #404
The neat thing is, with the new private-Key override we gain the feature of having a node signed by another node. This can be done by generating the node with a private key of another node and then renewing the keys to generate a new root key-pair signed by the previous one. The affect of which is having the node essentially signed by the other node. |
Loading a key that is created by another node is not exactly the same as cross-signing (PKI). See #154 for what I mean. |
…ootstrap.ts` This should allow us to override the keypair generation with the provided private key. this will speed up agent starting. Still need to test this for `agent start` and `bootstrap`. Related #404
…mandBootstrap.ts` This should allow us to override the keypair generation with the provided private key. this will speed up agent starting. Note that the key is provided as a Pem. The `PrivateKey` type contains functions that get destroyed somewhere between `commandStart.ts` and `keyManager.createKeyManager`. So I'm using the Pem string to keep the type primitive Related #404
The Pem is passed through I'm starting on removing the global agent in the tests now. |
I'm thinking you should call this parameter |
And yes you can pass newlines as environment variable. It's not a problem. Variables in shell Env can have newlines. |
Also if this parameter is specified, you have to ignore any usage of recovery code. It needs to be ignored. If the file is password protected you'll need both a password to decrypt it, and a password to encrypt it. So |
I'll double check the Env. As for the |
This is a quick and easy way to create an agent with a pre-generated key. Related #404
While this issue deals specifically with removing the global agent. The root key override can be used to optimise any test using a polykey agent, not just the bin tests. Such as the nodes, discovery, vaults? etc. I think these changes would be slightly out of the scope of this issue. So I should create a new issue for it. |
Looks like theres a bug with The error is
I think @emmacasolin wrote the tests for this. Do you have any idea why this is happening? It's coming from the discovery queue. Is it not ending properly during agent shutdown? |
I've also used the key override where needed for `createPolykeyAgent`. Related #404
It's an edge case, the discovery queue is handling |
This is done now. I'll create a new issue for the key generation override for all the other tests. |
This likely fixed #347, I'll include it in the PR. |
…erride` parameter for `createKeyManager` This will skip key generation and use the provided `PrivateKey` instead. This should speed up testing by skipping the key generation. Related #404
…mandBootstrap.ts` This should allow us to override the keypair generation with the provided private key. this will speed up agent starting. Note that the key is provided as a Pem. The `PrivateKey` type contains functions that get destroyed somewhere between `commandStart.ts` and `keyManager.createKeyManager`. So I'm using the Pem string to keep the type primitive Related #404
This is a quick and easy way to create an agent with a pre-generated key. Related #404
I've also used the key override where needed for `createPolykeyAgent`. Related #404
…erride` parameter for `createKeyManager` This will skip key generation and use the provided `PrivateKey` instead. This should speed up testing by skipping the key generation. Related #404
…mandBootstrap.ts` This should allow us to override the keypair generation with the provided private key. this will speed up agent starting. Note that the key is provided as a Pem. The `PrivateKey` type contains functions that get destroyed somewhere between `commandStart.ts` and `keyManager.createKeyManager`. So I'm using the Pem string to keep the type primitive Added `PK_ROOT_KEY` ENV and changed `--private-key-file` to `--root-key-file` Related #404
This is a quick and easy way to create an agent with a pre-generated key. Related #404
I've also used the key override where needed for `createPolykeyAgent`. Related #404
Specification
#264 introduced our global agent which is used in our tests as a way to reduce setup time (since we no longer need to create an agent for every test). However, this solution complicates our tests by requiring all side effects to be reversed (some side effects cannot be undone, e.g. sigchain changes and some identities changes) and preventing tests that use the global agent from running in parallel.
An alternative solution is to have a pre-generated root private key that we can pass into the
PolykeyAgent
creation. This should sidestep the key generation process and speed up agent creation significantly.Additional context
Tasks
KeyManager
generation to provide a root private key to skip root key-pair generation.PolykeyAgent
parameterspk agent start
andpk bootstrap
. Including new parameter + ENV variable.tests/fixtures
The text was updated successfully, but these errors were encountered: