Files
ziti/tests/testutil/control.go
T
Paul Lorenz e21d41df05 Notify controller of invalid destinations in routes.
Allow xgress and links to be destinguished by ID suffix
If a link destination is missing, send a link fault
Add forget-link router debug agent op to allow testing invalid
destinations
2022-04-26 22:16:58 -04:00

26 lines
876 B
Go

package testutil
import (
"github.com/openziti/channel"
"github.com/openziti/fabric/handler_common"
"github.com/openziti/fabric/pb/ctrl_pb"
"github.com/stretchr/testify/require"
"time"
)
func AcceptControl(id string, uf channel.UnderlayFactory, assertions *require.Assertions) (channel.Channel, *MessageCollector) {
msgc := NewMessageCollector(id)
bindHandler := func(binding channel.Binding) error {
binding.AddReceiveHandler(channel.AnyContentType, msgc)
binding.AddReceiveHandlerF(int32(ctrl_pb.ContentType_VerifyLinkType), func(msg *channel.Message, ch channel.Channel) {
handler_common.SendSuccess(msg, ch, "link success")
})
return nil
}
timeoutUF := NewTimeoutUnderlayFactory(uf, 2*time.Second)
ch, err := channel.NewChannel(id, timeoutUF, channel.BindHandlerF(bindHandler), channel.DefaultOptions())
assertions.NoError(err)
return ch, msgc
}