From af684146e0d94ed089bc7a53bc52e63a596c4300 Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Thu, 16 Jun 2022 22:57:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20SshPrivateKey=20json=20nam?= =?UTF-8?q?ing=20and=20extend=20tests.=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Preslav --- provisioner/buildinfo.go | 7 +++---- provisioner/buildinfo_test.go | 14 +++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/provisioner/buildinfo.go b/provisioner/buildinfo.go index 7627fcd..7e3800c 100644 --- a/provisioner/buildinfo.go +++ b/provisioner/buildinfo.go @@ -15,8 +15,7 @@ type BuildInfo struct { PackerRunUUID string `json:"PackerRunUUID"` Password string `json:"Password"` - SSHAgentAuth bool `json:"SSHAgentAuth"` - SSHPrivateKey string `json:"SSHPrivateKey"` - SSHPrivateKeyFile string `json:"SSHPrivateKeyFile"` - SSHPublicKey string `json:"SSHPrivateKeyFile"` + SSHAgentAuth bool `json:"SSHAgentAuth"` + SSHPrivateKey string `json:"SSHPrivateKey"` + SSHPublicKey string `json:"SSHPublicKey"` } diff --git a/provisioner/buildinfo_test.go b/provisioner/buildinfo_test.go index 7dffd97..dfb4cec 100644 --- a/provisioner/buildinfo_test.go +++ b/provisioner/buildinfo_test.go @@ -11,10 +11,22 @@ import ( func TestBuildInfo(t *testing.T) { data := ` - {"ConnType":"ssh","Host":"127.0.0.1","ID":"packer-alpine-1599666417","PackerHTTPAddr":"10.0.2.2:8644","PackerHTTPIP":"10.0.2.2","PackerHTTPPort":"8644","PackerRunUUID":"6ef27e2e-f4ea-be8e-7dc9-b1089998c001","Password":"vagrant","Port":2463,"SSHAgentAuth":false,"SSHPrivateKey":"","SSHPrivateKeyFile":"","SSHPublicKey":"","User":"vagrant","WinRMPassword":""} + {"ConnType":"ssh","Host":"127.0.0.1","ID":"packer-alpine-1599666417","PackerHTTPAddr":"10.0.2.2:8644","PackerHTTPIP":"10.0.2.2","PackerHTTPPort":"8644","PackerRunUUID":"6ef27e2e-f4ea-be8e-7dc9-b1089998c001","Password":"vagrant","Port":2463,"SSHAgentAuth":false,"SSHPrivateKey":"priv-key","SSHPublicKey":"pub-key","User":"vagrant","WinRMPassword":""} ` var buildInfo BuildInfo err := json.Unmarshal([]byte(data), &buildInfo) require.NoError(t, err) assert.Equal(t, "packer-alpine-1599666417", buildInfo.ID) + assert.Equal(t, "ssh", buildInfo.ConnType) + assert.Equal(t, "127.0.0.1", buildInfo.Host) + assert.Equal(t, 2463, buildInfo.Port) + assert.Equal(t, "vagrant", buildInfo.User) + assert.Equal(t, "vagrant", buildInfo.Password) + assert.Equal(t, "10.0.2.2:8644", buildInfo.PackerHTTPAddr) + assert.Equal(t, "10.0.2.2", buildInfo.PackerHTTPIP) + assert.Equal(t, "8644", buildInfo.PackerHTTPPort) + assert.Equal(t, "6ef27e2e-f4ea-be8e-7dc9-b1089998c001", buildInfo.PackerRunUUID) + assert.False(t, buildInfo.SSHAgentAuth) + assert.Equal(t, "priv-key", buildInfo.SSHPrivateKey) + assert.Equal(t, "pub-key", buildInfo.SSHPublicKey) }