Add extra test for verifiying ssh connection options (#817)
* Add extra test for verifiying ssh connection options * Fix failing manager test * Fix another test
This commit is contained in:
12
data/bookmark_with_ssh.toml
Normal file
12
data/bookmark_with_ssh.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
host = "localhost"
|
||||||
|
port = 5432
|
||||||
|
user = "postgres"
|
||||||
|
database = "mydatabase"
|
||||||
|
ssl = "disable"
|
||||||
|
|
||||||
|
[SSH]
|
||||||
|
host = "ssh-host"
|
||||||
|
user = "ssh-user"
|
||||||
|
password = "ssh-password"
|
||||||
|
key = "/path/to/key-file"
|
||||||
|
keypassword = "key-file-password"
|
||||||
@@ -12,7 +12,7 @@ func TestManagerList(t *testing.T) {
|
|||||||
num int
|
num int
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
{"../../data", 3, ""},
|
{"../../data", 4, ""},
|
||||||
{"../../data/bookmark.toml", 0, "is not a directory"},
|
{"../../data/bookmark.toml", 0, "is not a directory"},
|
||||||
{"../../data2", 0, ""},
|
{"../../data2", 0, ""},
|
||||||
{"", 0, ""},
|
{"", 0, ""},
|
||||||
@@ -32,7 +32,12 @@ func TestManagerList(t *testing.T) {
|
|||||||
func TestManagerListIDs(t *testing.T) {
|
func TestManagerListIDs(t *testing.T) {
|
||||||
ids, err := NewManager("../../data").ListIDs()
|
ids, err := NewManager("../../data").ListIDs()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, []string{"bookmark", "bookmark_invalid_ssl", "bookmark_url"}, ids)
|
assert.Equal(t, []string{
|
||||||
|
"bookmark",
|
||||||
|
"bookmark_invalid_ssl",
|
||||||
|
"bookmark_url",
|
||||||
|
"bookmark_with_ssh",
|
||||||
|
}, ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestManagerGet(t *testing.T) {
|
func TestManagerGet(t *testing.T) {
|
||||||
@@ -80,6 +85,19 @@ func Test_readBookmark(t *testing.T) {
|
|||||||
assert.Equal(t, "", b.Password)
|
assert.Equal(t, "", b.Password)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("with ssh options", func(t *testing.T) {
|
||||||
|
b, err := readBookmark("../../data/bookmark_with_ssh.toml")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotNil(t, b.SSH)
|
||||||
|
|
||||||
|
sshc := b.SSH
|
||||||
|
assert.Equal(t, "ssh-host", sshc.Host)
|
||||||
|
assert.Equal(t, "ssh-user", sshc.User)
|
||||||
|
assert.Equal(t, "ssh-password", sshc.Password)
|
||||||
|
assert.Equal(t, "/path/to/key-file", sshc.Key)
|
||||||
|
assert.Equal(t, "key-file-password", sshc.KeyPassword)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("invalid ssl", func(t *testing.T) {
|
t.Run("invalid ssl", func(t *testing.T) {
|
||||||
b, err := readBookmark("../../data/bookmark_invalid_ssl.toml")
|
b, err := readBookmark("../../data/bookmark_invalid_ssl.toml")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user