forked from nonspecialist/elktail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshtunnel_internal_test.go
35 lines (29 loc) · 1.32 KB
/
sshtunnel_internal_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Copyright (C) 2016 Krešimir Nesek
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
package main
import (
"github.com/bonovoxly/elktail/testutils"
"os"
"testing"
)
func TestNewSSHTunnelFromHostStrings(t *testing.T) {
InitLogging(os.Stderr, os.Stderr, os.Stderr, true)
tunnel := NewSSHTunnelFromHostStrings("[email protected]:2222", "9200:localhost:9200")
testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
testutils.AssertEqualsString(t, tunnel.Remote.Host, "localhost")
testutils.AssertEqualsInt(t, tunnel.Server.Port, 2222)
testutils.AssertEqualsInt(t, tunnel.Remote.Port, 9200)
testutils.AssertEqualsInt(t, tunnel.Local.Port, 9200)
tunnel = NewSSHTunnelFromHostStrings("test1.example.com:2222", "")
testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
testutils.AssertEqualsInt(t, tunnel.Server.Port, 2222)
tunnel = NewSSHTunnelFromHostStrings("[email protected]", "")
testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
testutils.AssertEqualsInt(t, tunnel.Server.Port, 22)
tunnel = NewSSHTunnelFromHostStrings("test1.example.com", "")
testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
testutils.AssertEqualsInt(t, tunnel.Server.Port, 22)
}