(t *testing.T)
| 2462 | } |
| 2463 | |
| 2464 | func 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 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…