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

Noyez vis change hist identity show #3699

Merged

Conversation

noyez
Copy link
Contributor

@noyez noyez commented Oct 20, 2022

Current Behavior

The ockam identity show --full command just shows a hex string representing many pieces of information.

Example before output:

$ ockam identity show --full --node n1
01cdb5565163e5b1278eb31e6dbd213066e335da0c3e5d8ffed3789ce1305...6778a9ae9204bf7fbc8adbc00138b2756a09

Proposed Changes

Decompose the hex string and display the data in a more human friendly format.

After:

$ ockam identity show --full --node n1
Change History:
  Change[0]:
    identifier: cdb5565163e5b1278eb31e6dbd213066e335da0c3e5d8ffed3789ce130523391
    change:
      prev_change_identifier: 0547c93239ba3d818ec26c9cdadd2a35cbdf1fa3b6d1a731e06164b1079fb7b8
      label:        OCKAM_RK
      public_key:   Ed25519 e7417e5ea17b05684cb56171f6f37ac92d37a03587fa43f66663bfda878a1322
    signatures:
      [0]: SelfSign 5e48f7a133ac1d9218f9fb7185cf890af6bbe9ca5ca58a741...9204bf7fbc8adbc00138b2756a09

This was implemented by de-serializing the original identity hex string using serde_bare and by adding the fmt::Display trait to the underlying types in the IdentityChangeHistory struct. There was a visibility change related to the IdentityChangeHistory struct, it went to pub from pub(crate) so that it can be de-serialized and used by the ockam_command crate.

Related Issue: #3258

Checks

@noyez noyez requested a review from a team as a code owner October 20, 2022 19:25
@mrinalwadhwa
Copy link
Member

@noyez this looks great. I'll read in more detail soon and leave some feedback.

In the meantime, before we can merge please

The easiest way to do this is to edit the CONTRIBUTORS.csv file in the github web UI and create a PR, this will make the commit as verified.

@noyez
Copy link
Contributor Author

noyez commented Oct 20, 2022

Hello @mrinalwadhwa -- I had added my details here:
https://github.com/build-trust/ockam-contributors/blob/main/CONTRIBUTORS.csv#L151

Perhaps i missed something else? Maybe i need to update/change my email?
thanks!

@mrinalwadhwa
Copy link
Member

@noyez ah yes, sorry I missed it in my quick check, you're all set no update needed.
I'll try out the changes soone.

Copy link
Member

@adrianbenavides adrianbenavides left a comment

Choose a reason for hiding this comment

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

@mrinalwadhwa tested and reviewed!

@noyez it would be awesome if you could add a test in the ockam_command/tests.commands.bats file. You could do something similar to the create a node and show its identity test.

@noyez
Copy link
Contributor Author

noyez commented Oct 25, 2022

@noyez it would be awesome if you could add a test in the ockam_command/tests.commands.bats file. You could do something similar to the create a node and show its identity test.

@adrianbenavides Sure I can do this. It appears that the purpose of testing ockam identity show --node n1 is to check that process exits with Zero (i.e. success) and its output matches some rules. Am I understanding this correctly?

Another possible test would be to test that a specific long identity string deserialized correctly into components with expected values. This test would be a typical rust test denoted w/ #cfg(test). If this sounds desirable i can add this kind of test too. Naively it would place such a test in implementations/rust/ockam/ockam_identity/src/change_history.rs, however there are no tests there. So perhaps there is a more central spot for such a test?

@adrianbenavides
Copy link
Member

adrianbenavides commented Oct 26, 2022

@adrianbenavides Sure I can do this. It appears that the purpose of testing ockam identity show --node n1 is to check that process exits with Zero (i.e. success) and its output matches some rules. Am I understanding this correctly?

That's right!

Another possible test would be to test that a specific long identity string deserialized correctly into components with expected values. This test would be a typical rust test denoted w/ #cfg(test). If this sounds desirable i can add this kind of test too. Naively it would place such a test in implementations/rust/ockam/ockam_identity/src/change_history.rs, however there are no tests there. So perhaps there is a more central spot for such a test?

We don't have a clear strategy for writing rust tests on the ockam_command crate that run nodes. The problem is that, since rust tests are executed in parallel, creating nodes might fail because it reads/writes to shared config files.

@noyez
Copy link
Contributor Author

noyez commented Oct 26, 2022

@adrianbenavides bat tests added.

This leads me to another question. When writing the test i realized i am assuming that an IdentityChangeHistory will always contain at least one IdentitySignedChange in its internal vector. Is there any point where the vector would be empty? If so, then I believe i'd need to change the test at the very least.

@noyez noyez force-pushed the noyez_vis_change_hist_identity_show branch from cad1310 to 5b47d8e Compare October 26, 2022 19:56
@adrianbenavides
Copy link
Member

Is there any point where the vector would be empty?

No, it looks great as it is. The identity is always initialized with a IdentitySignedChange.

@adrianbenavides adrianbenavides self-requested a review October 27, 2022 10:47
@adrianbenavides adrianbenavides force-pushed the noyez_vis_change_hist_identity_show branch 2 times, most recently from 39d34c5 to 04ecf0b Compare October 27, 2022 10:51
@adrianbenavides adrianbenavides added auto-merge HACKTOBERFEST-ACCEPTED To be used when a PR is ready to merge or after it's merged labels Oct 27, 2022
Copy link
Member

@adrianbenavides adrianbenavides left a comment

Choose a reason for hiding this comment

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

Awesome contribution @noyez , thank you so much! 🥳

@adrianbenavides adrianbenavides force-pushed the noyez_vis_change_hist_identity_show branch from 04ecf0b to 8d95a5a Compare October 27, 2022 10:58
@adrianbenavides adrianbenavides self-requested a review October 27, 2022 11:27
@mergify mergify bot merged commit eafc1e3 into build-trust:develop Oct 27, 2022
@mrinalwadhwa mrinalwadhwa added HACKTOBERFEST-ACCEPTED-2022 and removed HACKTOBERFEST-ACCEPTED To be used when a PR is ready to merge or after it's merged labels Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants