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

Do not publish public keys extractable from ID #4020

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

JustinDrake
Copy link
Contributor

License: MIT
Signed-off-by: Justin Drake drakefjustin@gmail.com

Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

@JustinDrake these changes look good to me, and all the required deps have now been updated (in #4059). Last thing I'd like to see before merging this is a test or two showing that using an ed25519 key doesnt publish to the dht.

@whyrusleeping
Copy link
Member

(you'll want to rebase on latest master to make it all work)

@JustinDrake
Copy link
Contributor Author

@whyrusleeping I've rebased.

How do you suggest that the test be written? There are no tests for publisher.go that I can build upon. I'm not 100% sure how to test that PublishPublicKey is not called. (Its side effects include log.Debugf and the networking done in r.PutValue, but I don't know how to hook into them.)

@whyrusleeping
Copy link
Member

@vyzo could you help @JustinDrake out with some tests here?

@vyzo
Copy link
Contributor

vyzo commented Aug 1, 2017

@JustinDrake we can add a publisher_test.go file.

We can start with a simple test which directly tests the behaviour of PutRecordToRouting wrt to keys. Longer term we certainly want to add some more tests around the publisher code.

The side-effect of PublishPublicKey can be checked by looking at the ValueStore. You can just use r.GetValue -- that should return ErrNotFound if the key didn't get published.

@vyzo
Copy link
Contributor

vyzo commented Aug 1, 2017

Note that you can mock the network and even the value store.
We basically want to ensure that the code is correct and that an RSA key will get published, while an Ed25519 key will not.

@JustinDrake
Copy link
Contributor Author

@vyzo Thank you for the suggestions of using the value store, and of testing both the RSA and Ed25519 cases.

@whyrusleeping I now have a test that shows that an Ed25519 key does not publish to the DHT, and (bonus) a test that shows that an RSA key does publish to the DHT.

Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

A couple small things that would be nice to fix, but in general this LGTM.

errs := make(chan error, 2) // At most two errors (IPNS, and public key)

// Attempt to extract the public key from the ID
var extractedPublicKey = id.ExtractPublicKey()
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: extractedPublicKey := ... instead of using var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 👍

if err != nil {
t.Fatal(err)
}

Copy link
Member

Choose a reason for hiding this comment

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

for completeness sake, it might be good to check in the dstore to make sure theres no key being put there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed 👍

License: MIT
Signed-off-by: Justin Drake <drakefjustin@gmail.com>
@JustinDrake
Copy link
Contributor Author

Is this good to merge? :)

@whyrusleeping whyrusleeping merged commit d50a2b5 into ipfs:master Aug 29, 2017
@whyrusleeping
Copy link
Member

Thanks @JustinDrake!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants