MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestProxyProtocolTrustedSource

Function TestProxyProtocolTrustedSource

tests/smtp_test.go:72–114  ·  view source on GitHub ↗
(tt *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestProxyProtocolTrustedSource(tt *testing.T) {
73 tt.Parallel()
74 t := tests.NewT(tt)
75 t.DNS(map[string]mockdns.Zone{
76 "one.maddy.test.": {
77 TXT: []string{"v=spf1 ip4:127.0.0.17 -all"},
78 },
79 })
80 t.Port("smtp")
81 t.Config(`
82 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
83 hostname mx.maddy.test
84 tls off
85
86 proxy_protocol {
87 trust ` + tests.DefaultSourceIP.String() + ` ::1/128
88 tls off
89 }
90
91 defer_sender_reject no
92
93 check {
94 spf {
95 enforce_early yes
96 fail_action reject
97 }
98 }
99
100 deliver_to dummy
101 }
102 `)
103 t.Run(1)
104 defer t.Close()
105
106 conn := t.Conn("smtp")
107 defer conn.Close()
108 conn.Writeln(fmt.Sprintf("PROXY TCP4 127.0.0.17 %s 12345 %d", tests.DefaultSourceIP.String(), t.Port("smtp")))
109 conn.SMTPNegotation("localhost", nil, nil)
110 conn.Writeln("MAIL FROM:<testing@one.maddy.test>")
111 conn.ExpectPattern("250 *")
112 conn.Writeln("QUIT")
113 conn.ExpectPattern("221 *")
114}
115
116func TestProxyProtocolUntrustedSource(tt *testing.T) {
117 tt.Parallel()

Callers

nothing calls this directly

Calls 12

DNSMethod · 0.95
PortMethod · 0.95
ConfigMethod · 0.95
RunMethod · 0.95
CloseMethod · 0.95
ConnMethod · 0.95
NewTFunction · 0.92
WritelnMethod · 0.80
SMTPNegotationMethod · 0.80
ExpectPatternMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected