Skip to content

Commit

Permalink
put publicKey field in json
Browse files Browse the repository at this point in the history
Former-commit-id: 183bbaa
  • Loading branch information
keyz-tk committed Dec 16, 2022
1 parent 4b5bbe1 commit 3eb9d25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func main() {
clifs.CreateFile(privateKeyFile, apiKey.TkPrivateKey, 0700)

jsonBytes, err := json.MarshalIndent(map[string]interface{}{
"publicKey": apiKey.TkPublicKey,
"publicKeyFile": publicKeyFile,
"privateKeyFile": privateKeyFile,
}, "", " ")
if err != nil {
log.Fatalf("Unable to serialize output to JSON: %v", err)
}
fmt.Println(string(jsonBytes))
fmt.Printf("\nYour public key for Turnkey is:\n%s\n", apiKey.TkPublicKey)
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 3eb9d25

Please sign in to comment.