MCPcopy
hub / github.com/cilium/cilium / TestDecode_CustomMonitorDecoder

Function TestDecode_CustomMonitorDecoder

pkg/hubble/parser/threefour/parser_test.go:2464–2656  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2462}
2463
2464func TestDecode_CustomMonitorDecoder(t *testing.T) {
2465 getTemplate := func() *flowpb.Flow {
2466 template := &flowpb.Flow{
2467 EventType: &flowpb.CiliumEventType{Type: 5},
2468 Summary: flowpb.IPVersion_IPv4.String(),
2469 Type: flowpb.FlowType_L3_L4,
2470 Source: &flowpb.Endpoint{},
2471 Destination: &flowpb.Endpoint{},
2472 Ethernet: &flowpb.Ethernet{
2473 Source: srcMAC.String(),
2474 Destination: dstMAC.String(),
2475 },
2476 IP: &flowpb.IP{
2477 IpVersion: flowpb.IPVersion_IPv4,
2478 Source: localIP.String(),
2479 Destination: remoteIP.String(),
2480 },
2481 }
2482 return template
2483 }
2484
2485 testCases := []struct {
2486 name string
2487 opts []options.Option
2488 event any
2489 ipTuple ipTuple
2490 want *flowpb.Flow
2491 }{
2492 {
2493 name: "policy",
2494 event: monitor.PolicyVerdictNotify{
2495 Type: byte(monitorAPI.MessageTypePolicyVerdict),
2496 Source: localEP,
2497 Flags: monitorAPI.PolicyEgress,
2498 RemoteLabel: identity.NumericIdentity(remoteID),
2499 },
2500 opts: []options.Option{
2501 options.WithPolicyVerdictNotifyDecoder(func(data []byte, decoded *flowpb.Flow) (*monitor.PolicyVerdictNotify, error) {
2502 decoded.Uuid = "foobar"
2503 return &monitor.PolicyVerdictNotify{
2504 Type: byte(monitorAPI.MessageTypePolicyVerdict),
2505 Source: 1226,
2506 Flags: monitorAPI.PolicyEgress,
2507 RemoteLabel: identity.NumericIdentity(1337),
2508 }, nil
2509 }),
2510 },
2511 ipTuple: egressTuple,
2512 want: &flowpb.Flow{
2513 Source: &flowpb.Endpoint{ID: 1234},
2514 Destination: &flowpb.Endpoint{Identity: 1337},
2515 TrafficDirection: flowpb.TrafficDirection_EGRESS,
2516 Uuid: "foobar",
2517 IsReply: wrapperspb.Bool(false),
2518 Verdict: flowpb.Verdict_FORWARDED,
2519 },
2520 },
2521 {

Callers

nothing calls this directly

Calls 15

NumericIdentityTypeAlias · 0.92
WithTraceNotifyDecoderFunction · 0.92
WithDropNotifyDecoderFunction · 0.92
WithDebugCaptureDecoderFunction · 0.92
CreateL3L4PayloadFunction · 0.92
NewFunction · 0.70
StringMethod · 0.65
RunMethod · 0.65
LoggerMethod · 0.65
DecodeMethod · 0.65
AsSliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…