Documentation
¶
Index ¶
- Variables
- func CreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) ([]byte, error)
- func MustCreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) []byte
- type FakeCiliumClient
- func (c *FakeCiliumClient) EndpointList() ([]*models.Endpoint, error)
- func (c *FakeCiliumClient) GetEndpoint(id uint64) (*models.Endpoint, error)
- func (c *FakeCiliumClient) GetFqdnCache() ([]*models.DNSLookup, error)
- func (c *FakeCiliumClient) GetIPCache() ([]*models.IPListEntry, error)
- func (c *FakeCiliumClient) GetIdentity(id uint64) (*models.Identity, error)
- func (c *FakeCiliumClient) GetServiceCache() ([]*models.Service, error)
- type FakeEndpointGetter
- type FakeEndpointsHandler
- func (f *FakeEndpointsHandler) DeleteEndpoint(ep *v1.Endpoint)
- func (f *FakeEndpointsHandler) FindEPs(epID uint64, ns, pod string) []v1.Endpoint
- func (f *FakeEndpointsHandler) GetEndpoint(ip net.IP) (ep *v1.Endpoint, ok bool)
- func (f *FakeEndpointsHandler) GetEndpointByContainerID(id string) (ep *v1.Endpoint, ok bool)
- func (f *FakeEndpointsHandler) GetEndpointByPodName(namespace string, name string) (ep *v1.Endpoint, ok bool)
- func (f *FakeEndpointsHandler) SyncEndpoints(eps []*v1.Endpoint)
- func (f *FakeEndpointsHandler) UpdateEndpoint(ep *v1.Endpoint)
- type FakeFQDNCache
- type FakeFlow
- func (f *FakeFlow) GetDestination() *pb.Endpoint
- func (f *FakeFlow) GetDestinationNames() []string
- func (f *FakeFlow) GetDestinationService() *pb.Service
- func (f *FakeFlow) GetDropReason() uint32
- func (f *FakeFlow) GetEthernet() *pb.Ethernet
- func (f *FakeFlow) GetEventType() *pb.CiliumEventType
- func (f *FakeFlow) GetIP() *pb.IP
- func (f *FakeFlow) GetL4() *pb.Layer4
- func (f *FakeFlow) GetL7() *pb.Layer7
- func (f *FakeFlow) GetNodeName() string
- func (f *FakeFlow) GetReply() bool
- func (f *FakeFlow) GetSource() *pb.Endpoint
- func (f *FakeFlow) GetSourceNames() []string
- func (f *FakeFlow) GetSourceService() *pb.Service
- func (f *FakeFlow) GetSummary() string
- func (f *FakeFlow) GetTime() *types.Timestamp
- func (f *FakeFlow) GetType() pb.FlowType
- func (f *FakeFlow) GetVerdict() pb.Verdict
- func (f *FakeFlow) ProtoMessage()
- func (f *FakeFlow) Reset()
- func (f *FakeFlow) String() string
- type FakeIPGetter
- type FakeIdentityGetter
- type FakeServiceGetter
Constants ¶
This section is empty.
Variables ¶
var NoopDNSGetter = FakeFQDNCache{ OnGetNamesOf: func(sourceEpID uint64, ip net.IP) (fqdns []string) { return nil }, }
NoopDNSGetter always returns an empty response.
var NoopEndpointGetter = FakeEndpointGetter{ OnGetEndpointInfo: func(ip net.IP) (endpoint v1.EndpointInfo, ok bool) { return nil, false }, }
NoopEndpointGetter always returns an empty response.
var NoopIPGetter = FakeIPGetter{ OnGetIPIdentity: func(ip net.IP) (id ipcache.IPIdentity, ok bool) { return ipcache.IPIdentity{}, false }, }
NoopIPGetter always returns an empty response.
var NoopIdentityGetter = FakeIdentityGetter{ OnGetIdentity: func(securityIdentity uint64) (*models.Identity, error) { return &models.Identity{}, nil }, }
NoopIdentityGetter always returns an empty response.
var NoopServiceGetter = FakeServiceGetter{ OnGetServiceByAddr: func(ip net.IP, port uint16) (service pb.Service, ok bool) { return pb.Service{}, false }, }
NoopServiceGetter always returns an empty response.
Functions ¶
func CreateL3L4Payload ¶
func CreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) ([]byte, error)
CreateL3L4Payload assembles a L3/L4 payload for testing purposes
func MustCreateL3L4Payload ¶
func MustCreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) []byte
MustCreateL3L4Payload wraps CreateL3L4Payload, but panics on error
Types ¶
type FakeCiliumClient ¶
type FakeCiliumClient struct {
FakeEndpointList func() ([]*models.Endpoint, error)
FakeGetEndpoint func(uint64) (*models.Endpoint, error)
FakeGetIdentity func(uint64) (*models.Identity, error)
FakeGetFqdnCache func() ([]*models.DNSLookup, error)
FakeGetIPCache func() ([]*models.IPListEntry, error)
FakeGetServiceCache func() ([]*models.Service, error)
}
FakeCiliumClient implements CliliumClient interface for unit testing.
func (*FakeCiliumClient) EndpointList ¶
func (c *FakeCiliumClient) EndpointList() ([]*models.Endpoint, error)
EndpointList calls FakeEndpointList.
func (*FakeCiliumClient) GetEndpoint ¶
func (c *FakeCiliumClient) GetEndpoint(id uint64) (*models.Endpoint, error)
GetEndpoint calls FakeGetEndpoint.
func (*FakeCiliumClient) GetFqdnCache ¶
func (c *FakeCiliumClient) GetFqdnCache() ([]*models.DNSLookup, error)
GetFqdnCache calls FakeGetFqdnCache.
func (*FakeCiliumClient) GetIPCache ¶
func (c *FakeCiliumClient) GetIPCache() ([]*models.IPListEntry, error)
GetIPCache calls FakeGetIPCache.
func (*FakeCiliumClient) GetIdentity ¶
func (c *FakeCiliumClient) GetIdentity(id uint64) (*models.Identity, error)
GetIdentity calls FakeGetIdentity.
func (*FakeCiliumClient) GetServiceCache ¶
func (c *FakeCiliumClient) GetServiceCache() ([]*models.Service, error)
GetServiceCache calls FakeGetServiceCache.
type FakeEndpointGetter ¶
type FakeEndpointGetter struct {
OnGetEndpointInfo func(ip net.IP) (endpoint v1.EndpointInfo, ok bool)
}
FakeEndpointGetter is used for unit tests that needs EndpointGetter.
func (*FakeEndpointGetter) GetEndpointInfo ¶
func (f *FakeEndpointGetter) GetEndpointInfo(ip net.IP) (endpoint v1.EndpointInfo, ok bool)
GetEndpointInfo implements EndpointGetter.GetEndpointInfo.
type FakeEndpointsHandler ¶
type FakeEndpointsHandler struct {
FakeSyncEndpoints func([]*v1.Endpoint)
FakeUpdateEndpoint func(*v1.Endpoint)
FakeDeleteEndpoint func(*v1.Endpoint)
FakeFindEPs func(epID uint64, ns, pod string) []v1.Endpoint
FakeGetEndpoint func(ip net.IP) (endpoint *v1.Endpoint, ok bool)
FakeGetEndpointByContainerID func(id string) (endpoint *v1.Endpoint, ok bool)
FakeGetEndpointByPodName func(namespace string, name string) (*v1.Endpoint, bool)
}
FakeEndpointsHandler implements EndpointsHandler interface for unit testing.
func (*FakeEndpointsHandler) DeleteEndpoint ¶
func (f *FakeEndpointsHandler) DeleteEndpoint(ep *v1.Endpoint)
DeleteEndpoint calls FakeDeleteEndpoint.
func (*FakeEndpointsHandler) FindEPs ¶
func (f *FakeEndpointsHandler) FindEPs(epID uint64, ns, pod string) []v1.Endpoint
FindEPs calls FakeFindEPs.
func (*FakeEndpointsHandler) GetEndpoint ¶
GetEndpoint calls FakeGetEndpoint.
func (*FakeEndpointsHandler) GetEndpointByContainerID ¶
func (f *FakeEndpointsHandler) GetEndpointByContainerID(id string) (ep *v1.Endpoint, ok bool)
GetEndpointByContainerID calls FakeGetEndpointByContainerID.
func (*FakeEndpointsHandler) GetEndpointByPodName ¶
func (f *FakeEndpointsHandler) GetEndpointByPodName(namespace string, name string) (ep *v1.Endpoint, ok bool)
GetEndpointByPodName calls FakeGetEndpointByPodName.
func (*FakeEndpointsHandler) SyncEndpoints ¶
func (f *FakeEndpointsHandler) SyncEndpoints(eps []*v1.Endpoint)
SyncEndpoints calls FakeSyncEndpoints.
func (*FakeEndpointsHandler) UpdateEndpoint ¶
func (f *FakeEndpointsHandler) UpdateEndpoint(ep *v1.Endpoint)
UpdateEndpoint calls FakeUpdateEndpoint.
type FakeFQDNCache ¶
type FakeFQDNCache struct {
OnInitializeFrom func(entries []*models.DNSLookup)
OnAddDNSLookup func(epID uint64, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32)
OnGetNamesOf func(epID uint64, ip net.IP) []string
}
FakeFQDNCache is used for unit tests that needs FQDNCache and/or DNSGetter.
func (*FakeFQDNCache) AddDNSLookup ¶
func (f *FakeFQDNCache) AddDNSLookup(epID uint64, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32)
AddDNSLookup implements FQDNCache.AddDNSLookup.
func (*FakeFQDNCache) GetNamesOf ¶
func (f *FakeFQDNCache) GetNamesOf(epID uint64, ip net.IP) []string
GetNamesOf implements FQDNCache.GetNameOf.
func (*FakeFQDNCache) InitializeFrom ¶
func (f *FakeFQDNCache) InitializeFrom(entries []*models.DNSLookup)
InitializeFrom implements FQDNCache.InitializeFrom.
type FakeFlow ¶
type FakeFlow struct {
Time *types.Timestamp
Verdict pb.Verdict
DropReason uint32
Ethernet *pb.Ethernet
IP *pb.IP
L4 *pb.Layer4
Source *pb.Endpoint
Destination *pb.Endpoint
Type pb.FlowType
NodeName string
SourceNames []string
DestinationNames []string
L7 *pb.Layer7
Reply bool
EventType *pb.CiliumEventType
SourceService *pb.Service
DestinationService *pb.Service
}
FakeFlow implements v1.Flow for unit tests. All interface methods return values exposed in the fields.
func (*FakeFlow) GetDestination ¶
GetDestination implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationNames ¶
GetDestinationNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationService ¶
GetDestinationService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDropReason ¶
GetDropReason implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEthernet ¶
GetEthernet implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEventType ¶
func (f *FakeFlow) GetEventType() *pb.CiliumEventType
GetEventType implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetNodeName ¶
GetNodeName implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceNames ¶
GetSourceNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceService ¶
GetSourceService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSummary ¶
GetSummary implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetVerdict ¶
GetVerdict implements v1.Flow for the FakeFlow.
func (*FakeFlow) ProtoMessage ¶
func (f *FakeFlow) ProtoMessage()
ProtoMessage implements pb.Message for the FakeFlow.
type FakeIPGetter ¶
type FakeIPGetter struct {
OnGetIPIdentity func(ip net.IP) (id ipcache.IPIdentity, ok bool)
}
FakeIPGetter is used for unit tests that needs IPGetter.
func (*FakeIPGetter) GetIPIdentity ¶
func (f *FakeIPGetter) GetIPIdentity(ip net.IP) (id ipcache.IPIdentity, ok bool)
GetIPIdentity implements FakeIPGetter.GetIPIdentity.
type FakeIdentityGetter ¶
type FakeIdentityGetter struct {
OnGetIdentity func(securityIdentity uint64) (*models.Identity, error)
}
FakeIdentityGetter is used for unit tests that need IdentityGetter.
func (*FakeIdentityGetter) GetIdentity ¶
func (f *FakeIdentityGetter) GetIdentity(securityIdentity uint64) (*models.Identity, error)
GetIdentity implements IdentityGetter.GetIPIdentity.
type FakeServiceGetter ¶
type FakeServiceGetter struct {
OnGetServiceByAddr func(ip net.IP, port uint16) (service pb.Service, ok bool)
}
FakeServiceGetter is used for unit tests that need ServiceGetter.
func (*FakeServiceGetter) GetServiceByAddr ¶
GetServiceByAddr implements FakeServiceGetter.GetServiceByAddr.