Documentation ¶
Overview ¶
Copyright 2019 Authors of Hubble Copyright 2020 Authors of Cilium
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func CreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) ([]byte, error)
- func MustCreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) []byte
- type FakeEndpointGetter
- type FakeFQDNCache
- type FakeFlow
- func (f *FakeFlow) GetDestination() *flowpb.Endpoint
- func (f *FakeFlow) GetDestinationNames() []string
- func (f *FakeFlow) GetDestinationService() *flowpb.Service
- func (f *FakeFlow) GetDropReason() uint32
- func (f *FakeFlow) GetEthernet() *flowpb.Ethernet
- func (f *FakeFlow) GetEventType() *flowpb.CiliumEventType
- func (f *FakeFlow) GetIP() *flowpb.IP
- func (f *FakeFlow) GetL4() *flowpb.Layer4
- func (f *FakeFlow) GetL7() *flowpb.Layer7
- func (f *FakeFlow) GetNodeName() string
- func (f *FakeFlow) GetPolicyMatchType() uint32
- func (f *FakeFlow) GetReply() bool
- func (f *FakeFlow) GetSource() *flowpb.Endpoint
- func (f *FakeFlow) GetSourceNames() []string
- func (f *FakeFlow) GetSourceService() *flowpb.Service
- func (f *FakeFlow) GetSummary() string
- func (f *FakeFlow) GetTime() *timestamp.Timestamp
- func (f *FakeFlow) GetTrafficDirection() flowpb.TrafficDirection
- func (f *FakeFlow) GetType() flowpb.FlowType
- func (f *FakeFlow) GetVerdict() flowpb.Verdict
- func (f *FakeFlow) ProtoMessage()
- func (f *FakeFlow) Reset()
- func (f *FakeFlow) String() string
- type FakeGRPCServerStream
- func (s *FakeGRPCServerStream) Context() context.Context
- func (s *FakeGRPCServerStream) RecvMsg(m interface{}) error
- func (s *FakeGRPCServerStream) SendHeader(m metadata.MD) error
- func (s *FakeGRPCServerStream) SendMsg(m interface{}) error
- func (s *FakeGRPCServerStream) SetHeader(m metadata.MD) error
- func (s *FakeGRPCServerStream) SetTrailer(m metadata.MD)
- type FakeGetFlowsServer
- type FakeIPGetter
- type FakeIdentityGetter
- type FakeServiceGetter
Constants ¶
This section is empty.
Variables ¶
var NoopDNSGetter = FakeFQDNCache{ OnGetNamesOf: func(sourceEpID uint32, 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 uint32) (*models.Identity, error) { return &models.Identity{}, nil }, }
NoopIdentityGetter always returns an empty response.
var NoopServiceGetter = FakeServiceGetter{ OnGetServiceByAddr: func(ip net.IP, port uint16) (service flowpb.Service, ok bool) { return flowpb.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 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 FakeFQDNCache ¶
type FakeFQDNCache struct { OnInitializeFrom func(entries []*models.DNSLookup) OnAddDNSLookup func(epID uint32, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32) OnGetNamesOf func(epID uint32, ip net.IP) []string }
FakeFQDNCache is used for unit tests that needs FQDNCache and/or DNSGetter.
func (*FakeFQDNCache) AddDNSLookup ¶
func (f *FakeFQDNCache) AddDNSLookup(epID uint32, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32)
AddDNSLookup implements FQDNCache.AddDNSLookup.
func (*FakeFQDNCache) GetNamesOf ¶
func (f *FakeFQDNCache) GetNamesOf(epID uint32, ip net.IP) []string
GetNamesOf implements FQDNCache.GetNameOf.
func (*FakeFQDNCache) InitializeFrom ¶
func (f *FakeFQDNCache) InitializeFrom(entries []*models.DNSLookup)
InitializeFrom implements FQDNCache.InitializeFrom.
type FakeFlow ¶ added in v1.8.0
type FakeFlow struct { Time *timestamp.Timestamp Verdict flowpb.Verdict DropReason uint32 Ethernet *flowpb.Ethernet IP *flowpb.IP L4 *flowpb.Layer4 Source *flowpb.Endpoint Destination *flowpb.Endpoint Type flowpb.FlowType NodeName string SourceNames []string DestinationNames []string L7 *flowpb.Layer7 Reply bool EventType *flowpb.CiliumEventType SourceService *flowpb.Service DestinationService *flowpb.Service TrafficDirection flowpb.TrafficDirection PolicyMatchType uint32 }
FakeFlow implements v1.Flow for unit tests. All interface methods return values exposed in the fields.
func (*FakeFlow) GetDestination ¶ added in v1.8.0
GetDestination implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationNames ¶ added in v1.8.0
GetDestinationNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationService ¶ added in v1.8.0
GetDestinationService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDropReason ¶ added in v1.8.0
GetDropReason implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEthernet ¶ added in v1.8.0
GetEthernet implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEventType ¶ added in v1.8.0
func (f *FakeFlow) GetEventType() *flowpb.CiliumEventType
GetEventType implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetNodeName ¶ added in v1.8.0
GetNodeName implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetPolicyMatchType ¶ added in v1.8.0
GetPolicyMatchType implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceNames ¶ added in v1.8.0
GetSourceNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceService ¶ added in v1.8.0
GetSourceService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSummary ¶ added in v1.8.0
GetSummary implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetTrafficDirection ¶ added in v1.8.0
func (f *FakeFlow) GetTrafficDirection() flowpb.TrafficDirection
GetTrafficDirection implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetVerdict ¶ added in v1.8.0
GetVerdict implements v1.Flow for the FakeFlow.
func (*FakeFlow) ProtoMessage ¶ added in v1.8.0
func (f *FakeFlow) ProtoMessage()
ProtoMessage implements flowpb.Message for the FakeFlow.
type FakeGRPCServerStream ¶
type FakeGRPCServerStream struct { OnSetHeader func(metadata.MD) error OnSendHeader func(metadata.MD) error OnSetTrailer func(m metadata.MD) OnContext func() context.Context OnSendMsg func(m interface{}) error OnRecvMsg func(m interface{}) error }
func (*FakeGRPCServerStream) Context ¶
func (s *FakeGRPCServerStream) Context() context.Context
func (*FakeGRPCServerStream) RecvMsg ¶
func (s *FakeGRPCServerStream) RecvMsg(m interface{}) error
func (*FakeGRPCServerStream) SendHeader ¶
func (s *FakeGRPCServerStream) SendHeader(m metadata.MD) error
func (*FakeGRPCServerStream) SendMsg ¶
func (s *FakeGRPCServerStream) SendMsg(m interface{}) error
func (*FakeGRPCServerStream) SetHeader ¶
func (s *FakeGRPCServerStream) SetHeader(m metadata.MD) error
func (*FakeGRPCServerStream) SetTrailer ¶
func (s *FakeGRPCServerStream) SetTrailer(m metadata.MD)
type FakeGetFlowsServer ¶
type FakeGetFlowsServer struct { OnSend func(response *observerpb.GetFlowsResponse) error *FakeGRPCServerStream }
func (*FakeGetFlowsServer) Send ¶
func (s *FakeGetFlowsServer) Send(response *observerpb.GetFlowsResponse) error
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 uint32) (*models.Identity, error)
}
FakeIdentityGetter is used for unit tests that need IdentityGetter.
func (*FakeIdentityGetter) GetIdentity ¶
func (f *FakeIdentityGetter) GetIdentity(securityIdentity uint32) (*models.Identity, error)
GetIdentity implements IdentityGetter.GetIPIdentity.
type FakeServiceGetter ¶
type FakeServiceGetter struct {
OnGetServiceByAddr func(ip net.IP, port uint16) (service flowpb.Service, ok bool)
}
FakeServiceGetter is used for unit tests that need ServiceGetter.
func (*FakeServiceGetter) GetServiceByAddr ¶
func (f *FakeServiceGetter) GetServiceByAddr(ip net.IP, port uint16) (service flowpb.Service, ok bool)
GetServiceByAddr implements FakeServiceGetter.GetServiceByAddr.