From 4b5bbe1d07dcba636da0f36de261dc930c5c6bcc Mon Sep 17 00:00:00 2001 From: Keyan Zhang Date: Thu, 15 Dec 2022 14:10:10 -0800 Subject: [PATCH 1/2] Print public key after creation Former-commit-id: 24c8a0b871bdaac7bafab85a459aa008d5e9df98 --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 73f0172..0fde6d1 100644 --- a/main.go +++ b/main.go @@ -78,6 +78,7 @@ func main() { 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 From 3eb9d25fa142fdc92fcd181f27b15ec59dd5bfb7 Mon Sep 17 00:00:00 2001 From: Keyan Zhang Date: Fri, 16 Dec 2022 11:13:26 -0800 Subject: [PATCH 2/2] put `publicKey` field in json Former-commit-id: 183bbaa080a36e6500673637c46185959976e343 --- main.go | 2 +- main_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0fde6d1..930ebd4 100644 --- a/main.go +++ b/main.go @@ -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, }, "", " ") @@ -78,7 +79,6 @@ func main() { 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 diff --git a/main_test.go b/main_test.go index fd6da14..891de10 100644 --- a/main_test.go +++ b/main_test.go @@ -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") }