-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add command to generate cryptosign challenge #1
Add command to generate cryptosign challenge #1
Conversation
ad41d82
to
550c8a1
Compare
cmd/wampproto/helpers.go
Outdated
@@ -0,0 +1,16 @@ | |||
package main |
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.
should be moved out of the cmd package to the root of this repository. Create helpers.go at the root of the project
550c8a1
to
8414184
Compare
8414184
to
acc5548
Compare
helpers.go
Outdated
@@ -0,0 +1,16 @@ | |||
package wampproto_cli |
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.
package wampproto_cli | |
package wampprotocli |
helpers.go
Outdated
"encoding/hex" | ||
) | ||
|
||
func HexToBase64String(hexStr string) (string, 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.
func HexToBase64String(hexStr string) (string, error) { | |
func HexToBase64(hexStr string) (string, error) { |
helpers_test.go
Outdated
|
||
"github.com/stretchr/testify/require" | ||
|
||
main "github.com/xconnio/wampproto-cli" |
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.
main "github.com/xconnio/wampproto-cli" | |
main "github.com/xconnio/wampproto-cli" |
use the package name, not main
cmd/wampproto/main.go
Outdated
hello := messages.NewHello("realm1", "test", nil, nil, []string{"anonymous"}) | ||
serializer := &serializers.MsgPackSerializer{} | ||
data, err := serializer.Serialize(hello) | ||
const versionString = "0.1.0" |
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.
move inside the below const stanza
cmd/wampproto/main.go
Outdated
return c, nil | ||
} | ||
|
||
func Run(args []string) 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.
func Run(args []string) error { | |
func Run(args []string) error { |
This function may just return the output string and the error. Then it becomes super easy to work in tests as well. No hacks needed to check shell output
acc5548
to
6ef4708
Compare
6ef4708
to
9aeae3b
Compare
main "github.com/xconnio/wampproto-cli/cmd/wampproto" | ||
) | ||
|
||
func TestRunGenerateChallenge(t *testing.T) { |
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.
These tests can be simplified, no need to loop, no need to check regex. If the output is supposed to be hex, just decode and if it works its correct. Same for base64.
helpers_test.go
Outdated
} | ||
|
||
// test invalid HexStrings | ||
for _, rawStr := range []string{ |
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.
use t.Run() and make them named tests within.
cf8930a
to
2a5bd90
Compare
2a5bd90
to
b9e9b9e
Compare
No description provided.