forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix direct node dial from WebUI (gravitational#20785)
* Fix direct node dial from WebUI * Apply suggestion. * Revert last commit * Add test * Add comment * Wait for the node registration in UT
- Loading branch information
Showing
2 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1534,6 +1534,75 @@ func TestTerminalRouting(t *testing.T) { | |
} | ||
} | ||
|
||
func TestTerminalNameResolution(t *testing.T) { | ||
t.Parallel() | ||
s := newWebSuite(t) | ||
pack := s.authPack(t, "foo") | ||
|
||
llama := s.addNode(t, uuid.NewString(), "llama", "127.0.0.1:0") | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) | ||
t.Cleanup(cancel) | ||
|
||
// Wait for the node to be registered as the registration is asynchronous. | ||
require.Eventuallyf(t, func() bool { | ||
nodes, err := s.proxyClient.GetNodes(ctx, "default") | ||
require.NoError(t, err) | ||
|
||
return len(nodes) == 2 // one created by default and llama | ||
}, 5*time.Second, 200*time.Millisecond, "failed to register node") | ||
|
||
tests := []struct { | ||
name string | ||
target string | ||
serverID string | ||
serverHostname string | ||
port int | ||
}{ | ||
{ | ||
name: "registered node by name", | ||
target: "llama", | ||
serverID: llama.ID(), | ||
serverHostname: "llama", | ||
}, | ||
{ | ||
name: "registered node by address", | ||
target: llama.Addr(), | ||
serverID: llama.ID(), | ||
serverHostname: llama.Addr(), | ||
}, | ||
{ | ||
name: "direct dial", | ||
target: "[email protected]", | ||
serverID: "[email protected]", | ||
serverHostname: "[email protected]", | ||
}, | ||
{ | ||
name: "direct dial with port", | ||
target: "[email protected]:1234", | ||
serverID: "[email protected]", | ||
serverHostname: "[email protected]", | ||
port: 1234, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
ws, resp, err := s.makeTerminal(t, pack, withServer(tt.target)) | ||
require.NoError(t, err) | ||
t.Cleanup(func() { require.NoError(t, ws.Close()) }) | ||
|
||
require.Equal(t, tt.serverID, resp.ServerID) | ||
require.Equal(t, tt.serverHostname, resp.ServerHostname) | ||
require.Equal(t, tt.port, resp.ServerHostPort) | ||
}) | ||
} | ||
|
||
} | ||
|
||
func TestTerminalRequireSessionMfa(t *testing.T) { | ||
ctx := context.Background() | ||
env := newWebPack(t, 1) | ||
|