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

Fixing the pk identities claim command to augment DIs #278

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

emmacasolin
Copy link
Contributor

@emmacasolin emmacasolin commented Oct 28, 2021

Description

Currently the pk-identities claim command does not perform a DI augmentation. src/client/rpcIdentities.ts and src/bin/identities/claim.ts will need to be rewritten to address this.

Issues Fixed

Tasks

  1. Check that the provider is auhenticated
  2. Create an identity claim on the claiming node's sigchain
    • Inject the sigchain into identities rpc
    • Construct ClaimLinkIdentity object
    • Call sigchain.addClaim() to add the claim
  3. Publish the claim on the DI
    • Find a way to get the newly added claim from the sigchain
    • Decode the claim
    • Get the provider from identity manager
    • Call the publishClaim() method on the provider
  4. Return info to the caller (e.g. claimId and/or claim url)
  5. Write tests for augmentation
    • CLI command
    • rpc
  6. Replace identities exceptions with client service exceptions Fixing the pk identities claim command to augment DIs #278 (comment)

Final checklist

  • Domain specific tests
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@emmacasolin emmacasolin self-assigned this Oct 28, 2021
@emmacasolin
Copy link
Contributor Author

Is there a reason why ProviderMessage uses the parameter message rather than identityId? Because it seems like everywhere that uses it assumes it's an identity id:

message ProviderMessage {
  string provider_id = 1;
  string message = 2;
}

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Oct 29, 2021 via email

@emmacasolin
Copy link
Contributor Author

Not sure. Who wrote this?

Looks like it just hasn't been changed since it was first added months ago. I'll change it to identityId for clarity.

@emmacasolin
Copy link
Contributor Author

Since sigchain.addClaim() doesn't return the generated claim I'm getting the newly created identity claim by doing

await sigchain.addClaim(claimData);
const claimId = await sigchain.getLatestClaimId();
const claimEncoded = await sigchain.getClaim(claimId!);
const claimDecoded = claimsUtils.decodeClaim(claimEncoded);

Although this assumes that the most recent claim on the sigchain is the one we just created (i.e. no other claims will be generated by other processes in between addClaim and getLatestClaim) - is it ok to make this assumption?

@emmacasolin
Copy link
Contributor Author

I was running into issues with importing the sigchain into rpc identities where I was getting an undefined error after trying to run a function from the sigchain domain. To get around this I've created a function called claimIdentity() in NodeManager to do the creation of the claim, adding it onto the sigchain, and returning the encoded claim which seems to be working and is probably better design anyway over having all of the logic in rpcIdentities.ts.

The augmentation process now seems to work in a simple test in clientService.test.ts, although there are still a few bugs that need to be ironed out, as well as tests in bin/identities.test.ts that need to be done, so this will probably be finished sometime on Monday.

@CMCDragonkai
Copy link
Member

@tegefaulkes is changing the proto schema in #279, so this may need to be updated on that.

@emmacasolin
Copy link
Contributor Author

I'm having some issues with the identities bin tests where the identities claim test is interfering with the identities discover (by node) test later on, causing it to fail with Error: 2 UNKNOWN: Unknown Error. I'm assuming it's from some sort of state that isn't getting cleaned up, since skipping the claims test causes everything else to pass, however I'm having trouble working out what it is. At the moment I'm clearing the sigchain, claimed identities on the provider, registered providers, the node graph, and the gestalt graph:

await polykeyAgent.sigchain.clearDB();
await testProvider.delToken(testToken.identityId);
await polykeyAgent.nodes.clearDB();
await polykeyAgent.gestalts.clearDB();
await polykeyAgent.identities.delToken(testToken.providerId, testToken.identityId);

However none of these have solved the problem. Not sure what else it could possibly be...

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Nov 1, 2021 via email

@tegefaulkes
Copy link
Contributor

It's useful to know exactly what the error is. You'll want to find the RPC function throwing the error and add a console.error(err) in the catch block for it. That should give you some more information to work with.

@emmacasolin
Copy link
Contributor Author

Rebased

@joshuakarp
Copy link
Contributor

Since sigchain.addClaim() doesn't return the generated claim I'm getting the newly created identity claim by doing

await sigchain.addClaim(claimData);
const claimId = await sigchain.getLatestClaimId();
const claimEncoded = await sigchain.getClaim(claimId!);
const claimDecoded = claimsUtils.decodeClaim(claimEncoded);

Although this assumes that the most recent claim on the sigchain is the one we just created (i.e. no other claims will be generated by other processes in between addClaim and getLatestClaim) - is it ok to make this assumption?

My bad in only seeing this now.

It should be fine to actually make addClaim return the created claim, so we don't have to do this. Alternatively, you should acquire the sigchain's lock and perform this in a transaction instead to ensure it's a safe operation.

@joshuakarp
Copy link
Contributor

From our sprint meeting yesterday, I believe there'll also be some testing fixes to be done after the CLI MR on Gitlab is merged and we rebase on those changes.

@CMCDragonkai
Copy link
Member

The errors for rpcIdentities should be using domain-specific errors or client service errors.

client/rpcIdentities.ts
164:          throw Error(
203:        if (provider == null) throw Error(`Invalid provider: ${providerId}`);
208:        } else throw Error(`No identities found for provider: ${providerId}`);

@CMCDragonkai
Copy link
Member

We shouldn't be throwing generic errors anywhere, it should always be attached to the error hierarchy somewhere. So the 2 choices are client service errors or domain specific errors. If the identities domain is returning undefined, then the exception should in client service. We will later review the entire system of how to do this. There's general exceptions for something not existing in HTTP like 404. We can do something similar in this case.

Or we can propagate "undefined", which means one has to have a representation of undefined in protobuf. Details here: https://stackoverflow.com/a/64970700/582917

This has to be done in the #249 where we review how the API used in a larger scope.

@CMCDragonkai CMCDragonkai mentioned this pull request Nov 26, 2021
14 tasks
@joshuakarp
Copy link
Contributor

@emmacasolin can you provide an update on the status of this PR when you're back in?

It will also need to be rebased on master before merging.

@emmacasolin
Copy link
Contributor Author

@emmacasolin can you provide an update on the status of this PR when you're back in?

It will also need to be rebased on master before merging.

Will need to fix up the command to match the new cli style + double check tests but other than that this is done. Will probably be finished off today.

@emmacasolin
Copy link
Contributor Author

This has been rebased on master

@emmacasolin emmacasolin force-pushed the identities-augment branch 2 times, most recently from d84a164 to 53b73d5 Compare December 2, 2021 04:49
@emmacasolin
Copy link
Contributor Author

There's a lot of uncleared state in the identities bin tests, primarily once an identity is authenticated in any test it remains authenticated in future tests. So far I haven't been able to find a way to clear this between tests without destroying and recreating the entire IdentitiesManager, but will keep working on it. There are other things that are cleared at the end of individual tests rather than in before/after each blocks, so will try to clean this up too.

@emmacasolin
Copy link
Contributor Author

Still having an issue with a successful identity claim causing an error in "Should start discovery by node" in tests/bin/identities.test.ts. The error is "Error: key should be a string or a buffer" and it's thrown inside the gestaltsDiscoveryByNode rpc. I haven't yet narrowed down exactly where it's being thrown, but I have a hunch it might be a jose error. Will continue looking into it tomorrow.

@joshuakarp
Copy link
Contributor

Not sure if you've pushed your version, but that test seems to be passing on its own on my end:

 PASS  tests/bin/identities.test.ts (21.953 s)
  CLI Identities
    commandAllowGestalts
      ○ skipped Should allow permissions on node.
      ○ skipped Should allow permissions on Identity.
      ○ skipped Should fail on invalid inputs.
    commandDisallowGestalts
      ○ skipped Should disallow permissions on Node.
      ○ skipped Should disallow permissions on Identity.
      ○ skipped Should fail on invalid inputs.
    commandPermissionsGestalts
      ○ skipped Should get permissions on Node.
      ○ skipped Should get permissions on Identity.
    commandTrustGestalts
      ○ skipped Should set trust on Node.
      ○ skipped Should set trust on Identity.
      ○ skipped Should fail on invalid inputs.
    commandUntrustGestalts
      ○ skipped Should unset trust on Node.
      ○ skipped Should unset trust on Identity.
      ○ skipped Should fail on invalid inputs.
    commandClaimIdentity
      ○ skipped Should claim an identity.
      ○ skipped Should fail for unauthenticated identities.
    commandAuthenticateProvider
      ○ skipped Should authenticate an identity with a provider.
    commandGetGestalts
      ○ skipped Should list gestalt by Node
      ○ skipped Should list gestalt by Identity
    commandListGestalts
      ○ skipped Should list gestalts with permissions.
    commandSearchIdentities
      ○ skipped Should find a connected identity.
    commandDiscoverGestalts
      ✓ Should start discovery by Node (1136 ms)
      ○ skipped Should start discovery by Identity

Test Suites: 1 passed, 1 total
Tests:       22 skipped, 1 passed, 23 total
Snapshots:   0 total
Time:        22.013 s, estimated 27 s
Ran all test suites matching /tests\/bin\/identities.test.ts/i.
GLOBAL TEARDOWN

Seems like there's some interference between tests though when ran together:

 FAIL  tests/bin/identities.test.ts (28.247 s)
  CLI Identities
    commandAllowGestalts
      ✓ Should allow permissions on node. (228 ms)
      ✓ Should allow permissions on Identity. (164 ms)
      ✓ Should fail on invalid inputs. (135 ms)
    commandDisallowGestalts
      ✓ Should disallow permissions on Node. (73 ms)
      ✓ Should disallow permissions on Identity. (72 ms)
      ✓ Should fail on invalid inputs. (114 ms)
    commandPermissionsGestalts
      ✓ Should get permissions on Node. (72 ms)
      ✓ Should get permissions on Identity. (66 ms)
    commandTrustGestalts
      ✓ Should set trust on Node. (64 ms)
      ✓ Should set trust on Identity. (77 ms)
      ✓ Should fail on invalid inputs. (85 ms)
    commandUntrustGestalts
      ✓ Should unset trust on Node. (70 ms)
      ✓ Should unset trust on Identity. (60 ms)
      ✓ Should fail on invalid inputs. (85 ms)
    commandClaimIdentity
      ✓ Should claim an identity. (76 ms)
      ✕ Should fail for unauthenticated identities. (78 ms)
    commandAuthenticateProvider
      ✓ Should authenticate an identity with a provider. (52 ms)
    commandGetGestalts
      ✓ Should list gestalt by Node (74 ms)
      ✓ Should list gestalt by Identity (67 ms)
    commandListGestalts
      ✓ Should list gestalts with permissions. (198 ms)
    commandSearchIdentities
      ✓ Should find a connected identity. (55 ms)
    commandDiscoverGestalts
      ✕ Should start discovery by Node (1290 ms)
      ✓ Should start discovery by Identity (969 ms)

  ● CLI Identities › commandClaimIdentity › Should fail for unauthenticated identities.

    expect(received).toBeFalsy()

    Received: true

      575 |       ];
      576 |       const result = await testUtils.pkStdio(commands, {}, dataDir);
    > 577 |       expect(result.exitCode === 0).toBeFalsy(); // Fails..
          |                                     ^
      578 |     });
      579 |   });
      580 |   describe('commandAuthenticateProvider', () => {

      at Object.<anonymous> (tests/bin/identities.test.ts:577:37)

  ● CLI Identities › commandDiscoverGestalts › Should start discovery by Node

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      754 |       ];
      755 |       const result = await testUtils.pkStdio(commands, {}, dataDir);
    > 756 |       expect(result.exitCode).toBe(0);
          |                               ^
      757 |
      758 |       // We expect to find a gestalt now.
      759 |       const gestalt = await polykeyAgent.gestaltGraph.getGestalts();

      at Object.<anonymous> (tests/bin/identities.test.ts:756:31)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 21 passed, 23 total
Snapshots:   0 total
Time:        28.313 s
Ran all test suites matching /tests\/bin\/identities.test.ts/i.
GLOBAL TEARDOWN
npm ERR! Test failed.  See above for more details.

@emmacasolin
Copy link
Contributor Author

emmacasolin commented Dec 2, 2021 via email

@emmacasolin
Copy link
Contributor Author

I've found the source of the error, however I don't know enough about the nodes domain to work out why it's occurring or how to fix it. What's happening is that when the node graph is being set up in the discover by node test (using setNodeOps(), at some point when it's calculating the bucket index it receives undefined. Undefined is returned by getBucketIndex() when the index (before being packed as a lexicographic integer and returned) is calculated as -1, which occurs when source node and target node for calculateBucketIndex() are the same. This error occurs even if I clear the node graph between tests so I don't know why claiming an identity would be causing this issue?

@emmacasolin
Copy link
Contributor Author

emmacasolin commented Dec 14, 2021

Files intended to be changed in this PR:

identities claim cli command

  • src/bin/identities/CommandClaim.ts
  • src/client/rpcIdentities.ts
  • src/client/GRPCClientClient.ts
  • src/client/clientService.ts
  • src/PolykeyAgent.ts
  • tests/client/utils.ts

Provider message better name for message field (now identityId)

  • src/proto/schemas/polykey/v1/identities/identities.proto
  • src/proto/schemas/polykey/v1/client_service.proto
  • src/proto/js/polykey/v1/identities/identities_pb.d.ts
  • src/proto/js/polykey/v1/identities/identities_pb.js
  • src/proto/js/polykey/v1/client_service_grpc_pb.d.ts
  • src/proto/js/polykey/v1/client_service_grpc_pb.js
  • src/bin/identities/CommandAllow.ts
  • src/bin/identities/CommandAuthenticate.ts
  • src/bin/identities/CommandDisallow.ts
  • src/bin/identities/CommandDiscover.ts
  • src/bin/identities/CommandGet.ts
  • src/bin/identities/CommandPermissions.ts
  • src/bin/identities/CommandSearch.ts
  • src/bin/identities/CommandTrust.ts
  • src/bin/identities/CommandUntrust.ts
  • src/client/rpcGestalts.ts
  • tests/client/rpcGestalts.test.ts

Sigchain returns newly created claim

  • src/sigchain/Sigchain.ts

"Reset" option added to Test Provider to clear changes between tests

  • tests/identities/TestProvider.ts

Replacing indentities exceptions with domain/client specific exceptions

  • src/client/errors.ts

Tests

  • tests/bin/identities.test.ts
  • tests/client/rpcIdentities.test.ts

@CMCDragonkai
Copy link
Member

The map used in protobuf is not a ES6 map. It's google-protobuf library's own map. The documentation is here:

To convert it to a POJO:

// this is the closest way to do it, the X is whatever the field name is
Object.fromEntries(message.getXMap().entries());

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Dec 17, 2021

The provider authentication is working now. Naming of the protobuf messages came from https://datatracker.ietf.org/doc/html/rfc6749.

However there is one problem.

We have not dealt with stream cancellation from the client side.

If the client side cancels the stream, the server does not listen for this event. Therefore subsequent write calls just hang forever. And server does not have deadlines, so it's just hanging forever.

For example in the identitiesAuthenticate handler:

At the end where it tries to:

        await genWritable.next(authProcess);
        await genWritable.next(null);

The first call to write may never return and finish if the client has already cancelled the stream that genWritable is trying to write.

This is because in our grpc utilities, we have not been listening for any kind of cancellation event. But more over we don't even have a server-side deadline system.

There should 3 potential events that we will need to address in a later PR targetting #249 and #243 and #297:

  1. Deadline exceeded from client
  2. Client cancellation
  3. Timeout on server side when handling ANY stream/call - this is the last resort, if it reaches here, it means the client is so slow, the server just aborts whatever it is doing

@CMCDragonkai
Copy link
Member

@joshuakarp You need to update the TestProvider to do the same as GitHubProvider just as a dummy.

Unsuccessful cases in TestProvider is not testable yet. We'll have to address how to make our TestProvider more dynamic later.

@CMCDragonkai
Copy link
Member

After verifying all tests, lint, squash, and prepare to merge.

@CMCDragonkai CMCDragonkai marked this pull request as ready for review December 17, 2021 03:32
@joshuakarp
Copy link
Contributor

joshuakarp commented Dec 17, 2021

Running tests:

  • tests/bin: list secrets failed in secret.test.ts with a timeout error, but all others passed. The test passes when run on its own in both this branch and master. Also, because we've moved the browser call to CommandAuthenticate now, it does open a browser to test.com (the url used to "authenticate"). Will look into mocking this. this is now being correctly mocked as an empty function
~/Documents/Projects/js-polykey(identities-augment) » npm test -- tests/bin

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/bin"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
 PASS  tests/bin/identities.test.ts (47.781 s)
  CLI Identities
    commandAllowGestalts
      ✓ Should allow permissions on node. (435 ms)
      ✓ Should allow permissions on Identity. (829 ms)
      ✓ Should fail on invalid inputs. (371 ms)
    commandDisallowGestalts
      ✓ Should disallow permissions on Node. (141 ms)
      ✓ Should disallow permissions on Identity. (247 ms)
      ✓ Should fail on invalid inputs. (356 ms)
    commandPermissionsGestalts
      ✓ Should get permissions on Node. (183 ms)
      ✓ Should get permissions on Identity. (228 ms)
    commandTrustGestalts
      ✓ Should set trust on Node. (144 ms)
      ✓ Should set trust on Identity. (107 ms)
      ✓ Should fail on invalid inputs. (190 ms)
    commandUntrustGestalts
      ✓ Should unset trust on Node. (153 ms)
      ✓ Should unset trust on Identity. (122 ms)
      ✓ Should fail on invalid inputs. (296 ms)
    commandClaimIdentity
      ✓ Should claim an identity. (194 ms)
      ✓ Should fail for unauthenticated identities. (99 ms)
    commandAuthenticateProvider
      ✓ Should authenticate an identity with a provider. (259 ms)
    commandGetGestalts
      ✓ Should list gestalt by Node (160 ms)
      ✓ Should list gestalt by Identity (122 ms)
    commandListGestalts
      ✓ Should list gestalts with permissions. (567 ms)
    commandSearchIdentities
      ✓ Should find a connected identity. (141 ms)
    commandDiscoverGestalts
      ✓ Should start discovery by Node (3569 ms)
      ✓ Should start discovery by Identity (1896 ms)

 PASS  tests/bin/notifications.test.ts (48.022 s)
  CLI Notifications
    commandSendNotification
      ✓ Should send notification with permission. (970 ms)
      ✓ Should send notification without permission. (145 ms)
    commandReadNotifications
      ✓ Should read all notifications. (699 ms)
      ✓ Should read all unread notifications. (734 ms)
      ✓ Should read a fixed number of notifications. (510 ms)
      ✓ Should read notifications in reverse order. (605 ms)
      ✓ Should read no notifications. (74 ms)
      ✓ Should read all types of notifications. (360 ms)
    commandClearNotifications
      ✓ Should remove all notifications. (539 ms)

 PASS  tests/bin/utils.retryAuth.test.ts
  bin/utils retryAuthentication
    ✓ no retry on success (6 ms)
    ✓ no retry on generic error (5 ms)
    ✓ no retry on unattended call with PK_TOKEN and PK_PASSWORD (4 ms)
    ✓ no retry on unattended call with PK_TOKEN (2 ms)
    ✓ no retry on unattended call with PK_PASSWORD (2 ms)
    ✓ retry once on clientErrors.ErrorClientAuthMissing (5 ms)
    ✓ retry 2 times on clientErrors.ErrorClientAuthDenied (4 ms)
    ✓ retry 2+ times on clientErrors.ErrorClientAuthDenied until generic error (5 ms)

 PASS  tests/bin/keys.test.ts (70.175 s)
  CLI keys
    commandCertChain
      ✓ should get the certificate chain (2294 ms)
    commandGetCert
      ✓ should get the certificate (2192 ms)
    commandGetRootKeypair
      ✓ should get the root keypair (2007 ms)
    commandEncryptKeys
      ✓ should encrypt data (2000 ms)
    commandDecryptKeys
      ✓ should decrypt data (2688 ms)
    commandSignKeys
      ✓ should sign a file (2542 ms)
    commandVerifyKeys
      ✓ should verify a file (2092 ms)
    commandRenewKeypair
      ✓ should renew the keypair (12833 ms)
    commandResetKeyPair
      ✓ should reset the keypair (13023 ms)
    commandChangePassword
      ✓ should change the root password (9215 ms)

 FAIL  tests/bin/secret.test.ts (118.294 s)
  CLI secrets
    commandCreateSecret
      ✓ should create secrets (7781 ms)
    commandDeleteSecret
      ✓ should delete secrets (8335 ms)
    commandGetSecret
      ✓ should retrieve secrets (7466 ms)
    commandListSecrets
      ✕ should list secrets (20001 ms)
    commandNewDir
      ✓ should make a directory (14141 ms)
    commandRenameSecret
      ✓ should rename secrets (9193 ms)
    commandUpdateSecret
      ✓ should update secrets (8218 ms)
    commandNewDirSecret
      ✓ should add a directory of secrets (7552 ms)

  ● CLI secrets › commandListSecrets › should list secrets

    : Timeout - Async callback was not invoked within the 20000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 20000 ms timeout specified by jest.setTimeout.Error:

      125 |   });
      126 |   describe('commandListSecrets', () => {
    > 127 |     test('should list secrets', async () => {
          |     ^
      128 |       const vaultName = 'Vault4' as VaultName;
      129 |       const vault = await polykeyAgent.vaultManager.createVault(vaultName);
      130 |

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.<anonymous> (tests/bin/secret.test.ts:127:5)

 PASS  tests/bin/bootstrap.test.ts (126.648 s)
  bootstrap
    ✓ bootstraps node state (28392 ms)
    ✓ bootstrapping occupied node state (19497 ms)
    ✓ concurrent bootstrapping are coalesced (16818 ms)
    ✓ bootstrap when interrupted, requires fresh on next bootstrap (38287 ms)

 PASS  tests/bin/vaults.test.ts (133.889 s)
  CLI vaults
    commandListVaults
      ✓ should list all vaults (6139 ms)
    commandCreateVaults
      ✓ should create vaults (4362 ms)
    commandRenameVault
      ✓ should rename vault (1467 ms)
      ✓ should fail to rename non-existent vault (1796 ms)
    commandDeleteVault
      ✓ should delete vault (4765 ms)
    commandVaultStats
      ○ skipped should return the stats of a vault
    commandSetPermsVault
      ○ skipped should share a vault
    commandUnsetPermsVault
      ○ skipped should un-share a vault
    commandVaultPermissions
      ○ skipped should get permissions of a vault
    commandPullVault
      ○ skipped should clone a vault
      ○ skipped should pull a vault
    commandScanVault
      ○ skipped should scan a node for vaults
    commandVaultVersion
      ✓ should switch the version of a vault (12992 ms)
      ✓ should switch the version of a vault to the latest version (14156 ms)
      ✓ should handle invalid version IDs (2573 ms)
      ✓ should throw an error if the vault is not found (80 ms)
    commandVaultLog
      ✓ Should get all commits (16188 ms)
      ✓ should get a part of the log (16842 ms)
      ✓ should get a specific commit (16439 ms)
      ✎ todo test formatting of the output

 PASS  tests/bin/agent/stop.test.ts (88.189 s)
  stop
    ✓ stop LIVE agent (25933 ms)
    ✓ stopping is idempotent during concurrent calls and STOPPING or DEAD status (23710 ms)
    ✓ stopping starting agent results in error (15791 ms)
    ✓ stopping while unauthenticated does not stop (21305 ms)

 PASS  tests/bin/sessions.test.ts (25.103 s)
  CLI Sessions
    ✓ serial commands refresh the session token (2953 ms)
    ✓ unattended commands with invalid authentication should fail (1594 ms)
    ✓ prompt for password to authenticate attended commands (744 ms)
    ✓ re-prompts for password if unable to authenticate command (1356 ms)

 PASS  tests/bin/utils.test.ts
  bin/utils
    ✓ list in human and json format (1 ms)
    ✓ table in human and in json format
    ✓ dict in human and in json format (1 ms)

 PASS  tests/bin/polykey.test.ts
  polykey
    ✓ default help display (35 ms)

 PASS  tests/bin/agent/lockall.test.ts (21.15 s)
  lockall
    ✓ lockall deletes the session token (672 ms)
    ✓ lockall ensures reauthentication is required (1297 ms)
    ✓ lockall causes old session tokens to fail (1307 ms)

 PASS  tests/bin/agent/lock.test.ts (16.759 s)
  lock
    ✓ lock deletes the session token (643 ms)
    ✓ lock ensures reauthentication is required (1343 ms)

 PASS  tests/bin/agent/unlock.test.ts (11.912 s)
  unlock
    ✓ unlock acquires session token (934 ms)

 PASS  tests/bin/agent/status.test.ts (40.457 s)
  status
    ✓ status on STARTING, STOPPING, DEAD agent (13277 ms)
    ✓ status on missing agent (12 ms)
    status with global agent
      ✓ status on LIVE agent (883 ms)
      ✓ status on remote LIVE agent (992 ms)

 PASS  tests/bin/agent/start.test.ts (165.511 s)
  start
    ✓ start in foreground (16997 ms)
    ✓ start in background (15847 ms)
    ✓ concurrent starts are coalesced (8998 ms)
    ✓ concurrent bootstrap is coalesced (7359 ms)
    ✓ start with existing state (19499 ms)
    ✓ start when interrupted, requires fresh on next start (26731 ms)
    ✓ start from recovery code (42197 ms)
    ✓ start with network configuration (5788 ms)

 PASS  tests/bin/nodes.test.ts (175.838 s)
  CLI Nodes
    commandClaimNode
      ✓ Should send a gestalt invite (775 ms)
      ✓ Should send a gestalt invite (force invite) (841 ms)
      ✓ Should claim remote node (380 ms)
    commandPingNode
      ✓ Should return failure when pinging an offline node (43250 ms)
      ✓ Should return failure if can't find the node (41621 ms)
      ✓ Should return success when pinging a live node (228 ms)
    commandFindNode
      ✓ Should find an online node (197 ms)
      ✓ Should find an offline node (146 ms)
      ✓ Should fail to find an unknown node (40921 ms)
    commandAddNode
      ✓ Should add the node (36 ms)
      ✓ Should fail to add the node (invalid node ID) (25 ms)
      ✓ Should fail to add the node (invalid IP address) (30 ms)

Test Suites: 1 failed, 16 passed, 17 total
Tests:       1 failed, 7 skipped, 1 todo, 115 passed, 124 total
Snapshots:   0 total
Time:        176.138 s
Ran all test suites matching /tests\/bin/i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin
npm ERR! Test failed.  See above for more details.

  • running these bin tests a second time produced different timeout errors, so I'm not too worried:
~/Documents/Projects/js-polykey(identities-augment) » npm test -- tests/bin/         

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/bin/"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
 PASS  tests/bin/notifications.test.ts (31.534 s)
  CLI Notifications
    commandSendNotification
      ✓ Should send notification with permission. (1725 ms)
      ✓ Should send notification without permission. (228 ms)
    commandReadNotifications
      ✓ Should read all notifications. (1010 ms)
      ✓ Should read all unread notifications. (963 ms)
      ✓ Should read a fixed number of notifications. (558 ms)
      ✓ Should read notifications in reverse order. (693 ms)
      ✓ Should read no notifications. (57 ms)
      ✓ Should read all types of notifications. (398 ms)
    commandClearNotifications
      ✓ Should remove all notifications. (708 ms)

 PASS  tests/bin/identities.test.ts (35.234 s)
  CLI Identities
    commandAllowGestalts
      ✓ Should allow permissions on node. (282 ms)
      ✓ Should allow permissions on Identity. (428 ms)
      ✓ Should fail on invalid inputs. (335 ms)
    commandDisallowGestalts
      ✓ Should disallow permissions on Node. (143 ms)
      ✓ Should disallow permissions on Identity. (158 ms)
      ✓ Should fail on invalid inputs. (298 ms)
    commandPermissionsGestalts
      ✓ Should get permissions on Node. (151 ms)
      ✓ Should get permissions on Identity. (164 ms)
    commandTrustGestalts
      ✓ Should set trust on Node. (155 ms)
      ✓ Should set trust on Identity. (151 ms)
      ✓ Should fail on invalid inputs. (212 ms)
    commandUntrustGestalts
      ✓ Should unset trust on Node. (154 ms)
      ✓ Should unset trust on Identity. (149 ms)
      ✓ Should fail on invalid inputs. (213 ms)
    commandClaimIdentity
      ✓ Should claim an identity. (182 ms)
      ✓ Should fail for unauthenticated identities. (122 ms)
    commandAuthenticateProvider
      ✓ Should authenticate an identity with a provider. (228 ms)
    commandGetGestalts
      ✓ Should list gestalt by Node (147 ms)
      ✓ Should list gestalt by Identity (143 ms)
    commandListGestalts
      ✓ Should list gestalts with permissions. (506 ms)
    commandSearchIdentities
      ✓ Should find a connected identity. (151 ms)
    commandDiscoverGestalts
      ✓ Should start discovery by Node (4458 ms)
      ✓ Should start discovery by Identity (1667 ms)

 PASS  tests/bin/keys.test.ts (69.485 s)
  CLI keys
    commandCertChain
      ✓ should get the certificate chain (2847 ms)
    commandGetCert
      ✓ should get the certificate (2310 ms)
    commandGetRootKeypair
      ✓ should get the root keypair (2340 ms)
    commandEncryptKeys
      ✓ should encrypt data (3058 ms)
    commandDecryptKeys
      ✓ should decrypt data (3153 ms)
    commandSignKeys
      ✓ should sign a file (2535 ms)
    commandVerifyKeys
      ✓ should verify a file (2511 ms)
    commandRenewKeypair
      ✓ should renew the keypair (13849 ms)
    commandResetKeyPair
      ✓ should reset the keypair (15456 ms)
    commandChangePassword
      ✓ should change the root password (9467 ms)

 PASS  tests/bin/agent/stop.test.ts (112.971 s)
  stop
    ✓ stop LIVE agent (31994 ms)
    ✓ stopping is idempotent during concurrent calls and STOPPING or DEAD status (28428 ms)
    ✓ stopping starting agent results in error (12746 ms)
    ✓ stopping while unauthenticated does not stop (37801 ms)

 PASS  tests/bin/agent/status.test.ts (49.267 s)
  status
    ✓ status on STARTING, STOPPING, DEAD agent (13816 ms)
    ✓ status on missing agent (19 ms)
    status with global agent
      ✓ status on LIVE agent (1881 ms)
      ✓ status on remote LIVE agent (1411 ms)

 PASS  tests/bin/sessions.test.ts (16.781 s)
  CLI Sessions
    ✓ serial commands refresh the session token (4572 ms)
    ✓ unattended commands with invalid authentication should fail (3200 ms)
    ✓ prompt for password to authenticate attended commands (1564 ms)
    ✓ re-prompts for password if unable to authenticate command (2783 ms)

 FAIL  tests/bin/vaults.test.ts (131.302 s)
  CLI vaults
    commandListVaults
      ✓ should list all vaults (9252 ms)
    commandCreateVaults
      ✓ should create vaults (7167 ms)
    commandRenameVault
      ✓ should rename vault (2493 ms)
      ✓ should fail to rename non-existent vault (2312 ms)
    commandDeleteVault
      ✓ should delete vault (2749 ms)
    commandVaultStats
      ○ skipped should return the stats of a vault
    commandSetPermsVault
      ○ skipped should share a vault
    commandUnsetPermsVault
      ○ skipped should un-share a vault
    commandVaultPermissions
      ○ skipped should get permissions of a vault
    commandPullVault
      ○ skipped should clone a vault
      ○ skipped should pull a vault
    commandScanVault
      ○ skipped should scan a node for vaults
    commandVaultVersion
      ✓ should switch the version of a vault (13425 ms)
      ✓ should switch the version of a vault to the latest version (14519 ms)
      ✓ should handle invalid version IDs (2452 ms)
      ✓ should throw an error if the vault is not found (77 ms)
    commandVaultLog
      ✓ Should get all commits (21788 ms)
      ✕ should get a part of the log (23204 ms)
      ✓ should get a specific commit (17663 ms)
      ✎ todo test formatting of the output

  ● CLI vaults › commandVaultLog › should get a part of the log

    Timeout - Async callback was not invoked within the 20000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 20000 ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:27:45)

  ● CLI vaults › commandVaultLog › should get a part of the log

    expect(received).toContain(expected) // indexOf

    Expected substring: "821749c0d5cc1aa267d1f3847c015595ad92fdb6"
    Received string:    "commit ff3b7b30da40134efaeeaa33530865b140dd967d
    committer v05ro48c0l893rl18bnqreutai37atrqf5d7rsb3mlqr532mr4vsg
    Date: Fri Dec 17 2021
    secret2 deleted·
    commit 714aefa27daf815900d04e9f5af58bb5655db071
    committer v05ro48c0l893rl18bnqreutai37atrqf5d7rsb3mlqr532mr4vsg
    Date: Fri Dec 17 2021
    secret2 added·
    "

      643 |       expect(result.stdout).not.toContain(commit1Oid);
      644 |       expect(result.stdout).toContain(commit2Oid);
    > 645 |       expect(result.stdout).toContain(commit3Oid);
          |                             ^
      646 |     });
      647 |     test('should get a specific commit', async () => {
      648 |       const command = [

      at Object.<anonymous> (tests/bin/vaults.test.ts:645:29)
          at runMicrotasks (<anonymous>)

 PASS  tests/bin/agent/lock.test.ts (5.377 s)
  lock
    ✓ lock deletes the session token (1766 ms)
    ✓ lock ensures reauthentication is required (2323 ms)

 PASS  tests/bin/utils.retryAuth.test.ts
  bin/utils retryAuthentication
    ✓ no retry on success (2 ms)
    ✓ no retry on generic error (5 ms)
    ✓ no retry on unattended call with PK_TOKEN and PK_PASSWORD (2 ms)
    ✓ no retry on unattended call with PK_TOKEN (2 ms)
    ✓ no retry on unattended call with PK_PASSWORD (8 ms)
    ✓ retry once on clientErrors.ErrorClientAuthMissing (4 ms)
    ✓ retry 2 times on clientErrors.ErrorClientAuthDenied (2 ms)
    ✓ retry 2+ times on clientErrors.ErrorClientAuthDenied until generic error (3 ms)

 PASS  tests/bin/polykey.test.ts
  polykey
    ✓ default help display (37 ms)

 PASS  tests/bin/utils.test.ts
  bin/utils
    ✓ list in human and json format (2 ms)
    ✓ table in human and in json format (2 ms)
    ✓ dict in human and in json format (2 ms)

 PASS  tests/bin/agent/unlock.test.ts (7.238 s)
  unlock
    ✓ unlock acquires session token (1730 ms)

 FAIL  tests/bin/bootstrap.test.ts (142.26 s)
  bootstrap
    ✓ bootstraps node state (24169 ms)
    ✕ bootstrapping occupied node state (52779 ms)
    ✕ concurrent bootstrapping are coalesced (21117 ms)
    ✕ bootstrap when interrupted, requires fresh on next bootstrap (40574 ms)

  ● bootstrap › bootstrapping occupied node state

    : Timeout - Async callback was not invoked within the 40000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 40000 ms timeout specified by jest.setTimeout.Error:

      54 |     global.defaultTimeout * 2,
      55 |   );
    > 56 |   test(
         |   ^
      57 |     'bootstrapping occupied node state',
      58 |     async () => {
      59 |       const password = 'password';

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.<anonymous> (tests/bin/bootstrap.test.ts:56:3)

  ● bootstrap › concurrent bootstrapping are coalesced

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      103 |         dataDir,
      104 |       ));
    > 105 |       expect(exitCode).toBe(0);
          |                        ^
      106 |       const recoveryCode = stdout.trim();
      107 |       expect(
      108 |         recoveryCode.split(' ').length === 12 ||

      at Object.<anonymous> (tests/bin/bootstrap.test.ts:105:24)

  ● bootstrap › bootstrap when interrupted, requires fresh on next bootstrap

    : Timeout - Async callback was not invoked within the 40000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 40000 ms timeout specified by jest.setTimeout.Error:

      184 |     global.defaultTimeout * 2,
      185 |   );
    > 186 |   test(
          |   ^
      187 |     'bootstrap when interrupted, requires fresh on next bootstrap',
      188 |     async () => {
      189 |       const password = 'password';

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.<anonymous> (tests/bin/bootstrap.test.ts:186:3)

  ● bootstrap › bootstrap when interrupted, requires fresh on next bootstrap

    ENOTEMPTY: directory not empty, rmdir '/tmp/polykey-test-jHNa1T/polykey/state/keys'



INFO:KeyManager:Started KeyManager
INFO:KeyManager:Created KeyManager
INFO:DB:Creating DB
INFO:DB:Starting DB
INFO:DB:Setting DB path to /tmp/polykey-test-jHNa1T/polykey/state/db
INFO:DB:Started DB
INFO:DB:Created DB
INFO:IdentitiesManager:Creating IdentitiesManager
INFO:IdentitiesManager:Starting IdentitiesManager
INFO:IdentitiesManager:Started IdentitiesManager
INFO:IdentitiesManager:Created IdentitiesManager
INFO:Sigchain:Creating Sigchain
INFO:Sigchain:Starting Sigchain
INFO:Sigchain:Started Sigchain
INFO:Sigchain:Created Sigchain
INFO:ACL:Creating ACL
INFO:ACL:Starting ACL
INFO:ACL:Started ACL
INFO:ACL:Created ACL
INFO:GestaltGraph:Creating GestaltGraph
INFO:GestaltGraph:Starting GestaltGraph
INFO:GestaltGraph:Started GestaltGraph
INFO:GestaltGraph:Created GestaltGraph
INFO:ForwardProxy:Creating Forward Proxy
INFO:ForwardProxy:Created Forward Proxy
INFO:ReverseProxy:Creating Reverse Proxy
INFO:ReverseProxy:Created Reverse Proxy
INFO:NodeManager:Creating NodeManager
INFO:NodeManager:Starting NodeManager
INFO:NodeManager:Creating NodeGraph
INFO:NodeManager:Starting NodeGraph
INFO:NodeManager:Started NodeGraph
INFO:NodeManager:Created NodeGraph
INFO:NodeManager:Started NodeManager
INFO:NodeManager:Created NodeManager
INFO:VaultManager:Creating VaultManager
INFO:VaultManager:Created VaultManager
INFO:VaultManager:Starting VaultManager
INFO:VaultManager:Removing vaults directory at '/tmp/polykey-test-jHNa1T/polykey/state/vaults'
INFO:DB:Creating DB
INFO:DB:Starting DB
INFO:DB:Setting DB path to /tmp/polykey-test-jHNa1T/polykey/state/vaults
INFO:DB:Started DB
INFO:DB:Created DB
INFO:VaultManager:Starting EncryptedFS
INFO:VaultManager:Started EncryptedFS
INFO:VaultManager:Started VaultManager
INFO:NotificationsManager:Creating NotificationsManager
INFO:NotificationsManager:Starting NotificationsManager
INFO:NotificationsManager:Started NotificationsManager
INFO:NotificationsManager:Created NotificationsManager
INFO:SessionManager:Creating SessionManager
INFO:SessionManager:Starting SessionManager
INFO:SessionManager:Generating sessions key
INFO:SessionManager:Started SessionManager
INFO:SessionManager:Created SessionManager
INFO:polykey:Begin Status STOPPING
INFO:polykey:Writing Status file to /tmp/polykey-test-jHNa1T/polykey/status.json
INFO:polykey:Status is STOPPING
INFO:SessionManager:Stopping SessionManager
INFO:SessionManager:Stopped SessionManager
INFO:NotificationsManager:Stopping NotificationsManager
INFO:NotificationsManager:Stopped NotificationsManager
INFO:VaultManager:Stopping VaultManager
INFO:VaultManager:Stopping EncryptedFS
INFO:DB:Stopping DB
INFO:DB:Stopped DB
INFO:VaultManager:Stopped EncryptedFS
INFO:VaultManager:Stopped VaultManager
INFO:NodeManager:Stopping NodeManager
INFO:NodeManager:Stopping NodeGraph
INFO:NodeManager:Stopped NodeGraph
INFO:NodeManager:Stopped NodeManager
INFO:GestaltGraph:Stopping GestaltGraph
INFO:GestaltGraph:Stopped GestaltGraph
INFO:ACL:Stopping ACL
INFO:ACL:Stopped ACL
INFO:Sigchain:Stopping Sigchain
INFO:Sigchain:Stopped Sigchain
INFO:IdentitiesManager:Stopping IdentitiesManager
INFO:IdentitiesManager:Stopped IdentitiesManager
INFO:DB:Stopping DB
INFO:DB:Stopped DB
INFO:KeyManager:Stopping KeyManager
INFO:KeyManager:Stopped KeyManager
INFO:Schema:Stopping Schema
INFO:Schema:Stopped Schema
INFO:polykey:Stopping Status
INFO:polykey:Writing Status file to /tmp/polykey-test-jHNa1T/polykey/status.json
INFO:polykey:Status is DEAD
INFO:polykey:Bootstrapped /tmp/polykey-test-jHNa1T/polykey
(node:146958) UnhandledPromiseRejectionWarning: Error: Caught error after test environment was torn down

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false
(Use `node --trace-warnings ...` to show where the warning was created)
(node:146958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:146958) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
judge impulse disease elite ivory swamp gun child ask weather slow pupil enter blame symbol slide arctic vessel vacuum assist ginger brave timber sun
INFO:ReverseProxy:Stopped Reverse Proxy
INFO:ForwardProxy:Stopping Forward Proxy Server
INFO:ForwardProxy:Stopped Forward Proxy Server
INFO:GRPCServerAgent:Stopping GRPCServer
INFO:GRPCServerAgent:Stopped GRPCServer
INFO:GRPCServerClient:Stopping GRPCServer
INFO:GRPCServerClient:Stopped GRPCServer
INFO:GestaltGraph:Stopping GestaltGraph
INFO:GestaltGraph:Stopped GestaltGraph
INFO:ACL:Stopping ACL
INFO:ACL:Stopped ACL
INFO:Sigchain:Stopping Sigchain
INFO:Sigchain:Stopped Sigchain
INFO:IdentitiesManager:Stopping IdentitiesManager
INFO:IdentitiesManager:Stopped IdentitiesManager
INFO:DB:Stopping DB
INFO:DB:Stopped DB
INFO:KeyManager:Stopping KeyManager
INFO:KeyManager:Stopped KeyManager
INFO:Schema:Stopping Schema
INFO:Schema:Stopped Schema
INFO:Status:Stopping Status
INFO:Status:Writing Status file to /tmp/polykey-test-bin/status.json
INFO:Status:Status is DEAD
INFO:PolykeyAgent:Stopped PolykeyAgent
 PASS  tests/bin/agent/lockall.test.ts (32.631 s)
  lockall
    ✓ lockall deletes the session token (1469 ms)
    ✓ lockall ensures reauthentication is required (2675 ms)
    ✓ lockall causes old session tokens to fail (1762 ms)

 PASS  tests/bin/agent/start.test.ts (154.22 s)
  start
    ✓ start in foreground (16053 ms)
    ✓ start in background (17966 ms)
    ✓ concurrent starts are coalesced (10150 ms)
    ✓ concurrent bootstrap is coalesced (7685 ms)
    ✓ start with existing state (20025 ms)
    ✓ start when interrupted, requires fresh on next start (27912 ms)
    ✓ start from recovery code (44367 ms)
    ✓ start with network configuration (8061 ms)

 PASS  tests/bin/secret.test.ts (86.285 s)
  CLI secrets
    commandCreateSecret
      ✓ should create secrets (8533 ms)
    commandDeleteSecret
      ✓ should delete secrets (10543 ms)
    commandGetSecret
      ✓ should retrieve secrets (7254 ms)
    commandListSecrets
      ✓ should list secrets (19434 ms)
    commandNewDir
      ✓ should make a directory (13623 ms)
    commandRenameSecret
      ✓ should rename secrets (7031 ms)
    commandUpdateSecret
      ✓ should update secrets (4864 ms)
    commandNewDirSecret
      ✓ should add a directory of secrets (4110 ms)

 PASS  tests/bin/nodes.test.ts (163.39 s)
  CLI Nodes
    commandClaimNode
      ✓ Should send a gestalt invite (834 ms)
      ✓ Should send a gestalt invite (force invite) (1053 ms)
      ✓ Should claim remote node (455 ms)
    commandPingNode
      ✓ Should return failure when pinging an offline node (43196 ms)
      ✓ Should return failure if can't find the node (42267 ms)
      ✓ Should return success when pinging a live node (330 ms)
    commandFindNode
      ✓ Should find an online node (463 ms)
      ✓ Should find an offline node (269 ms)
      ✓ Should fail to find an unknown node (41615 ms)
    commandAddNode
      ✓ Should add the node (35 ms)
      ✓ Should fail to add the node (invalid node ID) (22 ms)
      ✓ Should fail to add the node (invalid IP address) (25 ms)

Test Suites: 2 failed, 15 passed, 17 total
Tests:       4 failed, 7 skipped, 1 todo, 112 passed, 124 total
Snapshots:   0 total
Time:        163.709 s, estimated 176 s
Ran all test suites matching /tests\/bin\//i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin
npm ERR! Test failed.  See above for more details.
----------------------------------------------------
  • tests/client: all passing
~/Documents/Projects/js-polykey(identities-augment*) » npm test -- tests/client 

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/client"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
 PASS  tests/client/rpcIdentities.test.ts (24.281 s)
  Identities Client service
    ✓ should authenticate an identity (337 ms)
    ✓ should manipulate tokens for providers (177 ms)
    ✓ should list providers. (51 ms)
    ✓ should list connected Identities. (50 ms)
    ✓ should get identity info. (67 ms)
    ✓ should claim an identity. (116 ms)

 PASS  tests/client/GRPCClientClient.test.ts (24.789 s)
  GRPCClientClient
    ✓ cannot be called when destroyed (150 ms)
    ✓ can get status (2313 ms)

 PASS  tests/client/rpcGestalts.test.ts (30.325 s)
  Client service
    ✓ should get all gestalts (436 ms)
    ✓ should set independent node and identity gestalts (134 ms)
    ✓ should get gestalt from Node. (230 ms)
    ✓ should get gestalt from identity. (269 ms)
    ✓ should discover gestalt via Node. (220 ms)
    ✓ should discover gestalt via Identity. (57 ms)
    ✓ should get gestalt permissions by node. (147 ms)
    ✓ should get gestalt permissions by Identity. (159 ms)
    ✓ should set gestalt permissions by node. (174 ms)
    ✓ should set gestalt permissions by Identity. (225 ms)
    ✓ should unset gestalt permissions by node. (152 ms)
    ✓ should unset gestalt permissions by Identity. (156 ms)

 PASS  tests/client/rpcAgent.test.ts (7.749 s)
  Agent client service
    ✓ stopping the agent (49 ms)

 PASS  tests/client/rpcSessions.test.ts (8.323 s)
  Sessions client service
    ✓ can request a session (38 ms)
    ✓ can lock all sessions (34 ms)

 PASS  tests/client/rpcKeys.test.ts (36.999 s)
  Keys client service
    ✓ should get root keypair (137 ms)
    ✓ should reset root keypair (7038 ms)
    ✓ should renew root keypair (5158 ms)
    ✓ should encrypt and decrypt with root keypair (262 ms)
    ✓ should sign and verify with root keypair (290 ms)
    ✓ should get the root certificate and chains (91 ms)

 PASS  tests/client/rpcVaults.test.ts (37.368 s)
  Vaults client service
    Vaults
      ○ skipped should get vaults
      ○ skipped should create vault
      ○ skipped should delete vaults
      ○ skipped should rename vaults
      Version
        ○ skipped should switch a vault to a version
        ○ skipped should fail to find a non existent version
      Vault Log
        ○ skipped should get the full log
        ○ skipped should get a part of the log
        ○ skipped should get a specific commit
    Secrets
      ✓ should add a directory of secrets in a vault (12326 ms)
      ○ skipped should make a directory in a vault
      ○ skipped should list secrets in a vault
      ○ skipped should delete secrets in a vault
      ○ skipped should edit secrets in a vault
      ○ skipped should get secrets in a vault
      ○ skipped should rename secrets in a vault
      ○ skipped should add secrets in a vault

 PASS  tests/client/rpcNotifications.test.ts (39.998 s)
  Notifications client service
    Notifications RPC
      ✓ should send notifications. (631 ms)
      ✓ should read all notifications. (730 ms)
      ✓ should read a single notification. (146 ms)
      ✓ should clear all notifications. (117 ms)

ERROR:rpcNodes Test:Failed CONNECT to 127.0.0.2:22222 - ErrorConnectionStartTimeout
  console.error
    Failed to connect to 127.0.0.2:22222/?nodeId=vi3et1hrpv2m2lrplcm7cu913kr45v51cak54vm68anlbvuf83ra0 through proxy 127.0.0.1:39955 with status 400

      at Object.<anonymous>.exports.log (node_modules/@grpc/grpc-js/src/logging.ts:57:13)
      at ClientRequest.<anonymous> (node_modules/@grpc/grpc-js/src/http_proxy.ts:269:9)

 FAIL  tests/client/rpcNodes.test.ts (88.455 s)
  Client service
    ✓ should add a node (123 ms)
    ✕ should ping a node (online + offline) (34158 ms)
    ✓ should find a node (local) (13 ms)
    ✓ should find a node (contacts remote node) (202 ms)
    ✓ should fail to find a node (contacts remote node) (20261 ms)
    ✓ should send a gestalt invite (no existing invitation) (32 ms)
    ✓ should send a gestalt invite (existing invitation) (227 ms)
    ✓ should claim node (123 ms)

  ● Client service › should ping a node (online + offline)

    ErrorUtilsPollTimeout:

      118 |     while (true) {
      119 |       if (timer?.timedOut) {
    > 120 |         throw new utilsErrors.ErrorUtilsPollTimeout();
          |               ^
      121 |       }
      122 |       try {
      123 |         result = await f();

      at poll (src/utils/utils.ts:120:15)
      at Object.waitFor (src/status/Status.ts:150:24)
      at Object.<anonymous> (tests/client/rpcNodes.test.ts:203:7)

Test Suites: 1 failed, 8 passed, 9 total
Tests:       1 failed, 16 skipped, 41 passed, 58 total
Snapshots:   0 total
Time:        88.76 s
Ran all test suites matching /tests\/client/i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin
npm ERR! Test failed.  See above for more details.

  • tests/identities: all passing after small fix
~/Documents/Projects/js-polykey(identities-augment*) » npm test -- tests/identities

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/identities"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
 PASS  tests/identities/IdentitiesManager.test.ts
  IdentitiesManager
    ✓ IdentitiesManager readiness (21 ms)
    ✓ get, set and unset tokens (19 ms)
    ✓ start and stop preserves state (5 ms)
    ✓ fresh start deletes all state (5 ms)
    ✓ register and unregister providers (9 ms)
    ✓ using TestProvider (19 ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        1.55 s, estimated 4 s
Ran all test suites matching /tests\/identities/i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin

  • sigchain: all passed
~/Documents/Projects/js-polykey(identities-augment*) » npm test -- tests/sigchain  

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/sigchain"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
 PASS  tests/sigchain/Sigchain.test.ts (14.317 s)
  Sigchain
    ✓ session readiness (883 ms)
    ✓ async start initialises the sequence number (1540 ms)
    ✓ adds and retrieves a cryptolink, verifies signature (1568 ms)
    ✓ adds and retrieves 2 cryptolinks, verifies signatures and hash (1449 ms)
    ✓ adds an existing claim (1858 ms)
    ✓ retrieves chain data (1333 ms)
    ✓ retrieves all cryptolinks (nodes and identities) from sigchain (in expected lexicographic order) (2425 ms)

Test Suites: 1 passed, 1 total
Tests:       7 passed, 7 total
Snapshots:   0 total
Time:        14.342 s
Ran all test suites matching /tests\/sigchain/i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin

~/Documents/Projects/js-polykey(identities-augment*) » npm test -- tests/discovery 

> @matrixai/[email protected] test /home/josh/Documents/Projects/js-polykey
> jest "tests/discovery"

Determining test suites to run...
GLOBAL SETUP
Creating global.keyPairDir: /tmp/polykey-test-keypair
Creating global.binAgentDir: /tmp/polykey-test-bin
  console.log
    WARN:ConnectionReverse 127.0.0.1:46816:Connection Error: Error [ERR_STREAM_WRITE_AFTER_END]: write after end

      at ConsoleHandler.emit (node_modules/@matrixai/logger/dist/handlers/ConsoleHandler.js:9:17)

  console.log
    WARN:ConnectionReverse 127.0.0.1:58831:Connection Error: Error [ERR_STREAM_WRITE_AFTER_END]: write after end

      at ConsoleHandler.emit (node_modules/@matrixai/logger/dist/handlers/ConsoleHandler.js:9:17)

  console.log
    WARN:ConnectionReverse 127.0.0.1:58831:Connection Error: Error [ERR_STREAM_WRITE_AFTER_END]: write after end

      at ConsoleHandler.emit (node_modules/@matrixai/logger/dist/handlers/ConsoleHandler.js:9:17)

 PASS  tests/discovery/Discovery.test.ts (34.712 s)
  Discovery
    Basic manager tests.
      ✓ Constructs. (2 ms)
      ✓ Starts and stops (1 ms)
    Discovery process
      ✓ discoverGestaltByNode by NodeId (1331 ms)
      ✓ discoverGestaltByNode by IdentityId (472 ms)
      ✓ discovery readiness (12 ms)
    End-to-end discovery between two gestalts
      ✓ Gestalt1 discovers Gestalt2 (655 ms)
      ✓ Gestalt2 discovers Gestalt1 (962 ms)

Test Suites: 1 passed, 1 total
Tests:       7 passed, 7 total
Snapshots:   0 total
Time:        34.737 s
Ran all test suites matching /tests\/discovery/i.
GLOBAL TEARDOWN
Destroying global.keyPairDir: /tmp/polykey-test-keypair
Destroying global.binAgentDir: /tmp/polykey-test-bin

@joshuakarp
Copy link
Contributor

Squashed and ready for merge.

Fix naming of `identityId` field of `Provider` proto message
Sigchain `addClaim()` method returns generated claim
"Reset" functionality for Test Provider
Replacing identities rpc exceptions with domain+client exceptions
Refactoring identitiesAuthenticate process to correctly use a stream and expected data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

The pk identities claim command should perform augmentation
4 participants