-
Notifications
You must be signed in to change notification settings - Fork 30
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
go testclient #93
go testclient #93
Conversation
6e9a1fb
to
026d786
Compare
@c633 @masomel @arlolra Whoever has time: I think this is ready for a first review. Start the server and play around with:
|
@@ -107,7 +107,7 @@ func (server *ConiksServer) makeHandler(acceptableTypes map[int]bool) func(msg [ | |||
response, e := server.dir.HandleOps(req) | |||
switch req.Type { | |||
case KeyLookupType, KeyLookupInEpochType, MonitoringType: | |||
server.RLock() | |||
server.RUnlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase this pull on top of master branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
fmt.Println("Error while retrieving repsonse: " + err.Error()) | ||
os.Exit(-1) | ||
} | ||
response, errCode := client.UnmarshalResponse(p.KeyLookupType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For L36 - L80, I think we will eventually have client.Verify(operationType, response)
function that wraps all these verifications. This function would also need to handle this TODO (https://github.com/coniks-sys/coniks-go/blob/master/client/cgo/verification.go#L40-L45), much like what you did below. What do you think?
The same for registration code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Do you think this should be done in this PR, too? (or in a separate one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in a separate one. I can handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in a separate one. I can handle this.
I could also take care of this (if you haven't started yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm working on this in #74. How do you feel about https://github.com/coniks-sys/coniks-go/blob/f0e42ca6d6ce4b0ade502a769f4b8727d8c295d8/client/client.go?
I think we should have a Client
struct in protocol
package and make msg.Verify()
's arguments as its fields. (I'm working on this)
c := res.Verify(name, []byte(res.AP.Leaf.Value), 0, nil, | ||
conf.SigningPubKey) | ||
// verify auth. path: | ||
if c != p.Passed || res.AP == nil || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this verification be included in res.Verify
? (see https://github.com/coniks-sys/coniks-go/blob/953f8fd0e24fb07f993c571bf38a4b7aed4db015/protocol/verification.go)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I guess this makes sense. Especially if we want a clear API someone can use as a reference to implement his own client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do so, should we also need to verify the hash chain as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can store the latest STR to client/config.toml
(with an explanation that that field is being used for testing only, the developers should actually store the latest STR in some persistent storages) and whenever the test client runs, it reads the latest STR from this config file. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do so, should we also need to verify the hash chain as well?
I think, yes we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can store the latest STR to client/config.toml
Yeah, maybe for testing purposes that's a good idea!
@liamsi I'm trying to run the test client with the following command:
and get the following error: |
@masomel It seems like you have to call it with |
|
||
The client looks for a file called 'config.toml' in its current working directory. | ||
If you prefer the config-file to be named or stored somewhere different you can | ||
specify where to look for the config with the -config flag. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-config
should be --config
or -c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed in: a1f8c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a mkConfig
is fair enough? (see my comment #93 (comment)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not fully understand your comment. I guess, you mean create a mkConfig
just for the client (makes sense); but how does that relate to storing the STR in the config, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you proposing that for boostraping the chain we should write the initial STR into the config file? If yes, mkConfig
is called before the server is started and hence before the first STR is created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to have a generated template file for the test client.
Are you proposing that for boostraping the chain we should write the initial STR into the config file?
It's a good idea. But do we run the test client on the same machine as the key server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to have a generated template file for the test client.
OK, makes sense.
It's a good idea. But do we run the test client on the same machine as the key server?
Currently, the testclient only works if ran on the same machine as the key-server: #90 (comment)
Eventually, this will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (mkConfig
) as discussed in 2638588
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
For more information consult: https://godoc.org/github.com/coniks-sys/coniks-go/bots | ||
|
||
Example call: | ||
coniksclient register -name Alice@twitter -key fake_test_key`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/-name/--name and s/-key/--key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have sticked with the short version of flags in the usage string (which I tried myself) ;-) Thanks for testing it! Fixed in bd8d071
fmt.Println("Succesfully registered name: " + name) | ||
// TODO Where should the client save seen STRs and the TB? | ||
// (or should it wait till the next epoch to see if the | ||
// TB was actually inserted?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There maybe have more than one TB since the client could also receive the TB of her contacts, and we definitely have to check if the TB as been included as promised. Given that we will have a ConiksClient
to store verified STRs and TBs (see 266d8cd#diff-75d470fe65b4ef49cd55654004d3edeaR29), I'm thinking that should we store both STRs and TBs in this struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There maybe have more than one TB since the client could also receive the TB of her contacts, and we definitely have to check if the TB as been included as promised.
The client struct looks definitely like a good idea and I agree this would be the good place to store STRs and TBs (at least in memory). The current ConiksClient
also only stores one TB, or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should store an array of TB. Wait me a sec.
} | ||
req, err := createLookupRequest(name) | ||
if err != nil { | ||
fmt.Println("Couldn'r create request!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit-picking: s/Couldn'r/Couldn't
"github.com/spf13/cobra" | ||
) | ||
|
||
// TODO figure out if this needs to be a separate command or we can simply re-use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can temporarily remove this command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed ...
Use: "register", | ||
Short: "Register a name-to-key binding.", | ||
Long: `Register a new name-to-key binding on the CONIKS-server. | ||
Note that, for the registration to work, the test-client needs to be running on the same machine as the key-server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #130 has landed, could we remove this note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also removed
7abbabc
to
ea9a12d
Compare
* An alternative to what's here could be to have responses use a protocol.DirSTR, rather than merkletree.SignedTreeRoot, but that might be unsatisfying for other reasons.
- It may easier for ppl to invoke `coniksclient` from terminal when they install the test client with `go install`. - Add README.md for client
…pe merkletree.RawAd
var res []byte | ||
if conf.RegAddress == "" { | ||
// fallback to conf.Address if empty | ||
conf.RegAddress = conf.Address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define a regAddress := conf.RegAddress
above and then set that here?
} | ||
|
||
func createRegistrationMsg(name, key string) ([]byte, error) { | ||
return json.Marshal(&p.Request{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably belongs in encoding.go
// TODO: Save the cc to verify the TB and for later | ||
// usage (TOFU checks) | ||
case p.ReqNameExisted: | ||
// Key-change isn't currently supported; see: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't be here for a key change because we won't get a .CheckPassed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should finish #133 first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, can we remove this comment in favour of a pointer to that then?
case p.ReqSuccess: | ||
key, err := response.GetKey() | ||
if err != nil { | ||
fmt.Println("Cannot the key from the response, error: " + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot get the key
I think this looks good. You should squash and merge it ;) |
I've followed the latest changes and I agree (I might be biased, though ;-). Thanks again for taking care and finishing/cleaning up this PR @c633 @arlolra! |
Minimalistic test-client. Part of #90.
Differences to a real client implementation:
testutils
package (which doesn't verify server's tls-cert. chain, for instance)I would prefer to have the current code reviewed and create separate (smaller) issues/PRs for the above bullet-points.
TODOs:
integrate with Add verification methods #74 as soon as it is mergedUpdate:Add TODOs for parts of the code where the actual client struct/methods from Add verification methods #74 would be used (actually tried to make use of the consistency checks as much as possible)