TestFilterExternalToInternal also tests ICMP
()
| 477 | |
| 478 | // TestFilterExternalToInternal also tests ICMP |
| 479 | func (it *FilterTestSuite) TestFilterExternalToInternal() { |
| 480 | t := it.T() |
| 481 | // set up file system interface |
| 482 | afs := afero.NewOsFs() |
| 483 | |
| 484 | cfg, err := config.ReadFileConfig(afs, ConfigPath) |
| 485 | require.NoError(t, err) |
| 486 | cfg.Env.DBConnection = dockerInfo.clickhouseConnection |
| 487 | cfg.Filtering.FilterExternalToInternal = false |
| 488 | it.cfg = cfg |
| 489 | require.NoError(t, err, "updating config should not return an error") |
| 490 | |
| 491 | require.False(t, cfg.Filtering.FilterExternalToInternal) |
| 492 | |
| 493 | // // import data |
| 494 | importResults, err := cmd.RunImportCmd(time.Now(), cfg, afs, "../test_data/valid_tsv", "filter_ext_to_int", false, true) |
| 495 | require.NoError(t, err) |
| 496 | |
| 497 | // connect to database |
| 498 | db, err := database.ConnectToDB(context.Background(), "filter_ext_to_int", cfg, nil) |
| 499 | require.NoError(t, err) |
| 500 | |
| 501 | // // there are ICMP connections that are only on connections that are external to internal |
| 502 | |
| 503 | type protoInfo struct { |
| 504 | PortProtoService string `ch:"port_proto_service"` |
| 505 | ConnCount uint64 `ch:"conn_count"` |
| 506 | BytesSent uint64 `ch:"bytes_sent"` |
| 507 | BytesReceived uint64 `ch:"bytes_received"` |
| 508 | } |
| 509 | |
| 510 | type testData struct { |
| 511 | src string |
| 512 | dst string |
| 513 | portInfoList []protoInfo |
| 514 | } |
| 515 | |
| 516 | testCases := []testData{ |
| 517 | { |
| 518 | src: "165.227.88.15", |
| 519 | dst: "192.168.88.2", |
| 520 | portInfoList: []protoInfo{ |
| 521 | {"icmp:3/3", 2, 4858, 0}, |
| 522 | }, |
| 523 | }, |
| 524 | { |
| 525 | src: "66.218.84.141", |
| 526 | dst: "10.55.100.107", |
| 527 | portInfoList: []protoInfo{ |
| 528 | {"icmp:3/3", 1, 240, 0}, |
| 529 | }, |
| 530 | }, |
| 531 | { |
| 532 | src: "66.218.84.141", |
| 533 | dst: "10.55.100.104", |
| 534 | portInfoList: []protoInfo{ |
| 535 | {"icmp:3/3", 1, 240, 0}, |
| 536 | }, |
nothing calls this directly
no test coverage detected