From 0bc354835465fca19c8ec278ec68f276ae706ca0 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Thu, 22 Aug 2024 00:04:49 +0200 Subject: [PATCH] agentlistener tested. --- pkg/comms/agentlistener_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkg/comms/agentlistener_test.go diff --git a/pkg/comms/agentlistener_test.go b/pkg/comms/agentlistener_test.go new file mode 100644 index 0000000..8a66deb --- /dev/null +++ b/pkg/comms/agentlistener_test.go @@ -0,0 +1,28 @@ +package comms + +import "git.wamblee.org/converge/pkg/testsupport" + +func (s *AgentServerTestSuite) Test_clientIdPassedAsLocalAddr() { + agentChannel, serverChannel := s.createCommChannel() + + clientId := "myid" + testsupport.RunAndWait( + &s.Suite, + func() any { + listener := NewAgentListener(agentChannel.Session) + connection, err := listener.Accept() + s.Nil(err) + // clientId identifyable as remote addr + s.Equal(clientId, connection.LocalAddr().String()) + return nil + }, + func() any { + connection, err := serverChannel.Session.OpenStream() + s.Nil(err) + gobChannel := NewGOBChannel(connection) + clientInfo := ClientInfo{ClientId: clientId} + err = SendWithTimeout(gobChannel, clientInfo) + s.Nil(err) + return nil + }) +}