mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 15:28:05 +00:00
e21d41df05
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
26 lines
876 B
Go
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
|
|
}
|