added initialization test

This commit is contained in:
Erik Brakkee 2024-08-21 17:11:32 +02:00
parent 61e95ab2eb
commit ce45c59d33
2 changed files with 24 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"io" "io"
"log" "log"
"math/rand"
"net/http" "net/http"
"testing" "testing"
"time" "time"
@ -141,6 +142,27 @@ func (s *AgentServerTestSuite) Test_ConnectThroughYamux() {
}) })
} }
func (s *AgentServerTestSuite) Test_Initialization() {
serverTestId := rand.Int()
agentShell := "agentshell"
testsupport.RunAndWait(
&s.Suite,
func() any {
serverInfo, err := AgentInitialization(s.agentConnection,
NewEnvironmentInfo(agentShell))
s.Nil(err)
s.Equal(serverTestId, serverInfo.TestId)
return nil
},
func() any {
serverInfo := ServerInfo{TestId: serverTestId}
environmentInfo, err := ServerInitialization(s.serverConnection, serverInfo)
s.Nil(err)
s.Equal(agentShell, environmentInfo.Shell)
return nil
})
}
func (s *AgentServerTestSuite) Test_ListenForAgentEvents() { func (s *AgentServerTestSuite) Test_ListenForAgentEvents() {
} }

View File

@ -50,6 +50,8 @@ type ProtocolVersion struct {
// initialization mesaage when agent connects to server // initialization mesaage when agent connects to server
type ServerInfo struct { type ServerInfo struct {
// used for testing only.
TestId int
} }
// confirmation message when agent connects // confirmation message when agent connects