Skip to content

Commit af561e0

Browse files
committed
chore: test eviction with used ports
1 parent 8a1e923 commit af561e0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

agent/agentssh/x11_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,17 @@ func TestServer_X11_EvictionLRU(t *testing.T) {
162162

163163
c := sshClient(t, ln.Addr().String())
164164

165+
// block off one port to test x11Forwarder evicts at highest port, not number of listeners.
166+
externalListener, err := inproc.Listen("tcp",
167+
fmt.Sprintf("localhost:%d", agentssh.X11StartPort+agentssh.X11DefaultDisplayOffset+1))
168+
require.NoError(t, err)
169+
defer externalListener.Close()
170+
165171
// Calculate how many simultaneous X11 sessions we can create given the
166172
// configured port range.
173+
167174
startPort := agentssh.X11StartPort + agentssh.X11DefaultDisplayOffset
168-
maxSessions := agentssh.X11MaxPort - startPort + 1
175+
maxSessions := agentssh.X11MaxPort - startPort + 1 - 1 // -1 for the blocked port
169176
require.Greater(t, maxSessions, 0, "expected a positive maxSessions value")
170177

171178
// shellSession holds references to the session and its standard streams so

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy