diff --git a/sshkeys.go b/sshkeys.go index 8080aee..b0ed2ec 100644 --- a/sshkeys.go +++ b/sshkeys.go @@ -2,16 +2,10 @@ package metadata import "context" -// SSHKeysUserData contains per-user SSH public keys -// specified during Linode instance/disk creation. -type SSHKeysUserData struct { - Root []string `json:"root"` -} - // SSHKeysData contains information about SSH keys // relevant to the current Linode instance. type SSHKeysData struct { - Users SSHKeysUserData `json:"users"` + Users map[string][]string `json:"users"` } // GetSSHKeys gets all SSH keys for the current instance. diff --git a/test/integration/sshkeys_test.go b/test/integration/sshkeys_test.go new file mode 100644 index 0000000..10a8b4a --- /dev/null +++ b/test/integration/sshkeys_test.go @@ -0,0 +1,24 @@ +package integration + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetSSHKeys(t *testing.T) { + t.Parallel() + + sshKeys, err := metadataClient.GetSSHKeys(context.Background()) + assert.NoError(t, err) + + if len(sshKeys.Users) < 1 { + t.Skip( + "The current instance does not have any SSH keys configured, skipping...") + } + + for _, v := range sshKeys.Users { + assert.Greater(t, len(v), 0) + } +}