Skip to content

Commit

Permalink
Merge pull request #4 from tkhq/keyan/show-public-key
Browse files Browse the repository at this point in the history
Print public key after creation

Former-commit-id: cb3744d
keyz authored Dec 16, 2022
2 parents 114f2e5 + 3eb9d25 commit ad8dece
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ func main() {
clifs.CreateFile(privateKeyFile, apiKey.TkPrivateKey, 0700)

jsonBytes, err := json.MarshalIndent(map[string]interface{}{
"publicKey": apiKey.TkPublicKey,
"publicKeyFile": publicKeyFile,
"privateKeyFile": privateKeyFile,
}, "", " ")
4 changes: 4 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -56,9 +56,13 @@ func TestKeygenInTmpFolder(t *testing.T) {
assert.FileExists(t, tmpDir+"/mykey.public")
assert.FileExists(t, tmpDir+"/mykey.private")

publicKeyData, err := os.ReadFile(tmpDir + "/mykey.public")
assert.Nil(t, err)

var parsedOut map[string]string
err = json.Unmarshal([]byte(out), &parsedOut)
assert.Nil(t, err)
assert.Equal(t, parsedOut["publicKey"], string(publicKeyData))
assert.Equal(t, parsedOut["publicKeyFile"], tmpDir+"/mykey.public")
assert.Equal(t, parsedOut["privateKeyFile"], tmpDir+"/mykey.private")
}

0 comments on commit ad8dece

Please sign in to comment.