MCPcopy Create free account
hub / github.com/appleboy/easyssh-proxy / TestProxyTimeoutHandling

Function TestProxyTimeoutHandling

easyssh_test.go:521–552  ·  view source on GitHub ↗

TestProxyTimeoutHandling tests that timeout is properly respected when using proxy connections This test uses a non-existent proxy server to force a timeout during proxy connection

(t *testing.T)

Source from the content-addressed store, hash-verified

519// TestProxyTimeoutHandling tests that timeout is properly respected when using proxy connections
520// This test uses a non-existent proxy server to force a timeout during proxy connection
521func TestProxyTimeoutHandling(t *testing.T) {
522 ssh := &MakeConfig{
523 Server: "example.com",
524 User: "testuser",
525 Port: "22",
526 KeyPath: "./tests/.ssh/id_rsa",
527 Timeout: 1 * time.Second, // Short timeout for testing
528 Proxy: DefaultConfig{
529 User: "testuser",
530 Server: "10.255.255.1", // Non-routable IP that should timeout
531 Port: "22",
532 KeyPath: "./tests/.ssh/id_rsa",
533 Timeout: 1 * time.Second,
534 },
535 }
536
537 // Test Connect() method directly to test proxy connection timeout
538 start := time.Now()
539 session, client, err := ssh.Connect()
540 elapsed := time.Since(start)
541
542 // Should timeout within reasonable bounds
543 assert.True(t, elapsed < 3*time.Second, "Connection should timeout within 3 seconds, took %v", elapsed)
544 assert.True(t, elapsed >= 1*time.Second, "Connection should take at least 1 second (timeout value), took %v", elapsed)
545
546 // Should return nil session and client
547 assert.Nil(t, session)
548 assert.Nil(t, client)
549
550 // Should have error
551 assert.NotNil(t, err)
552}
553
554// TestProxyDialTimeout tests the specific scenario described in issue #93
555// where proxy dial timeout should be respected and properly detected

Callers

nothing calls this directly

Calls 1

ConnectMethod · 0.95

Tested by

no test coverage detected