MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseFirewallLogLine

Function TestParseFirewallLogLine

pkg/cli/firewall_log_test.go:15–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestParseFirewallLogLine(t *testing.T) {
16 tests := []struct {
17 name string
18 line string
19 expected *FirewallLogEntry
20 }{
21 {
22 name: "valid log line with all fields",
23 line: `1761332530.474 172.30.0.20:35288 api.enterprise.githubcopilot.com:443 140.82.112.22:443 1.1 CONNECT 200 TCP_TUNNEL:HIER_DIRECT api.enterprise.githubcopilot.com:443 "-"`,
24 expected: &FirewallLogEntry{
25 Timestamp: "1761332530.474",
26 ClientIPPort: "172.30.0.20:35288",
27 Domain: "api.enterprise.githubcopilot.com:443",
28 DestIPPort: "140.82.112.22:443",
29 Proto: "1.1",
30 Method: "CONNECT",
31 Status: "200",
32 Decision: "TCP_TUNNEL:HIER_DIRECT",
33 URL: "api.enterprise.githubcopilot.com:443",
34 UserAgent: "-",
35 },
36 },
37 {
38 name: "log line with placeholder values",
39 line: `1761332530.500 - - - - - 0 NONE_NONE:HIER_NONE - "-"`,
40 expected: &FirewallLogEntry{
41 Timestamp: "1761332530.500",
42 ClientIPPort: "-",
43 Domain: "-",
44 DestIPPort: "-",
45 Proto: "-",
46 Method: "-",
47 Status: "0",
48 Decision: "NONE_NONE:HIER_NONE",
49 URL: "-",
50 UserAgent: "-",
51 },
52 },
53 {
54 name: "empty line",
55 line: "",
56 expected: nil,
57 },
58 {
59 name: "comment line",
60 line: "# This is a comment",
61 expected: nil,
62 },
63 {
64 name: "invalid timestamp (non-numeric)",
65 line: `WARNING: 172.30.0.20:35288 api.github.com:443 140.82.112.22:443 1.1 CONNECT 200 TCP_TUNNEL:HIER_DIRECT api.github.com:443 "-"`,
66 expected: nil,
67 },
68 {
69 name: "non-standard client IP:port format is accepted",
70 line: `1761332530.474 Accepting api.github.com:443 140.82.112.22:443 1.1 CONNECT 200 TCP_TUNNEL:HIER_DIRECT api.github.com:443 "-"`,
71 expected: &FirewallLogEntry{
72 Timestamp: "1761332530.474",

Callers

nothing calls this directly

Calls 3

parseFirewallLogLineFunction · 0.70
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected