Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
eb11d78b
Commit
eb11d78b
authored
Apr 23, 2015
by
Fabio Yeon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7187 from akram/fix_port_forward_listner_parsing_ipv4_ipv6_2
Fixes port_forward unit tests which fails on machine which ::1 does not resolve to localhost
parents
c303c055
0883bfa6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
portforward_test.go
pkg/client/portforward/portforward_test.go
+22
-12
No files found.
pkg/client/portforward/portforward_test.go
View file @
eb11d78b
...
@@ -209,14 +209,16 @@ func (s *fakeUpgradeStream) Headers() http.Header {
...
@@ -209,14 +209,16 @@ func (s *fakeUpgradeStream) Headers() http.Header {
return
http
.
Header
{}
return
http
.
Header
{}
}
}
type
TestCase
struct
{
Hostname
string
Protocol
string
ShouldRaiseError
bool
ExpectedListenerAddress
string
}
func
TestGetListener
(
t
*
testing
.
T
)
{
func
TestGetListener
(
t
*
testing
.
T
)
{
var
pf
PortForwarder
var
pf
PortForwarder
testCases
:=
[]
struct
{
testCases
:=
[]
TestCase
{
Hostname
string
Protocol
string
ShouldRaiseError
bool
ExpectedListenerAddress
string
}{
{
{
Hostname
:
"localhost"
,
Hostname
:
"localhost"
,
Protocol
:
"tcp4"
,
Protocol
:
"tcp4"
,
...
@@ -236,12 +238,6 @@ func TestGetListener(t *testing.T) {
...
@@ -236,12 +238,6 @@ func TestGetListener(t *testing.T) {
ExpectedListenerAddress
:
"::1"
,
ExpectedListenerAddress
:
"::1"
,
},
},
{
{
Hostname
:
"localhost"
,
Protocol
:
"tcp6"
,
ShouldRaiseError
:
false
,
ExpectedListenerAddress
:
"::1"
,
},
{
Hostname
:
"[::1]"
,
Hostname
:
"[::1]"
,
Protocol
:
"tcp4"
,
Protocol
:
"tcp4"
,
ShouldRaiseError
:
true
,
ShouldRaiseError
:
true
,
...
@@ -253,6 +249,20 @@ func TestGetListener(t *testing.T) {
...
@@ -253,6 +249,20 @@ func TestGetListener(t *testing.T) {
},
},
}
}
// On some linux systems, ::1 does not resolve to localhost but to localhost6 or
// ip6-localhost. To make the test case portable, we need to do a reverse lookup on ::1 and
// trying to bind a port with the name.
names
,
err
:=
net
.
LookupAddr
(
"::1"
)
if
err
==
nil
&&
len
(
names
)
>
0
{
ipv6TestCase
:=
TestCase
{
Hostname
:
names
[
0
],
Protocol
:
"tcp6"
,
ShouldRaiseError
:
false
,
ExpectedListenerAddress
:
"::1"
,
}
testCases
=
append
(
testCases
,
ipv6TestCase
)
}
for
i
,
testCase
:=
range
testCases
{
for
i
,
testCase
:=
range
testCases
{
expectedListenerPort
:=
"12345"
expectedListenerPort
:=
"12345"
listener
,
err
:=
pf
.
getListener
(
testCase
.
Protocol
,
testCase
.
Hostname
,
&
ForwardedPort
{
12345
,
12345
})
listener
,
err
:=
pf
.
getListener
(
testCase
.
Protocol
,
testCase
.
Hostname
,
&
ForwardedPort
{
12345
,
12345
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment