agent registers with duplica id

This commit is contained in:
Erik Brakkee 2024-08-22 11:24:27 +02:00
parent 1244e34de5
commit 37ff504b88

View File

@ -77,7 +77,7 @@ func (s *AdminTestSuite) agentRegisters(requestedPublicId, assignedPublicId stri
res := testsupport.RunAndWait(
&s.Suite,
func() any {
return s.addAgent(requestedPublicId, serverRW)
return s.addAgent(requestedPublicId, assignedPublicId, serverRW)
},
func() any {
return s.agentRegistration(assignedPublicId, agentRW)
@ -112,7 +112,11 @@ func (s *AdminTestSuite) Test_ManyAgentsRegister() {
agentConn := entry.(*agentConnection)
s.Equal(agentConn.Info, state.Agents[agentConn.Info.Guid])
}
}
func (s *AdminTestSuite) Test_agentDuplicateId() {
s.agentRegisters("abc", "abc")
s.agentRegisters("abc", "abc-0")
}
func (s *AdminTestSuite) agentRegistration(expectedPublicId string, agentRW io.ReadWriteCloser) any {
@ -129,12 +133,12 @@ func (s *AdminTestSuite) agentRegistration(expectedPublicId string, agentRW io.R
return nil
}
func (s *AdminTestSuite) addAgent(publicId string, serverRW io.ReadWriteCloser) any {
func (s *AdminTestSuite) addAgent(publicId string, assignedPublicId string, serverRW io.ReadWriteCloser) any {
agentConn, err := s.admin.AddAgent(
s.hostKey, models.RendezVousId(publicId), comms.EnvironmentInfo{},
serverRW)
s.Nil(err)
s.Equal(publicId, string(agentConn.Info.PublicId))
s.Equal(assignedPublicId, string(agentConn.Info.PublicId))
return agentConn
}