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

Function TestProxyProtocolUntrustedSource

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

Source from the content-addressed store, hash-verified

114}
115
116func TestProxyProtocolUntrustedSource(tt *testing.T) {
117 tt.Parallel()
118 t := tests.NewT(tt)
119 t.DNS(map[string]mockdns.Zone{
120 "one.maddy.test.": {
121 TXT: []string{"v=spf1 ip4:127.0.0.17 -all"},
122 },
123 })
124 t.Port("smtp")
125 t.Config(`
126 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
127 hostname mx.maddy.test
128 tls off
129
130 proxy_protocol {
131 trust fe80::bad/128
132 tls off
133 }
134
135 defer_sender_reject no
136
137 check {
138 spf {
139 enforce_early yes
140 fail_action reject
141 }
142 }
143
144 deliver_to dummy
145 }
146 `)
147 t.Run(1)
148 defer t.Close()
149
150 conn := t.Conn("smtp")
151 defer conn.Close()
152 conn.Writeln(fmt.Sprintf("PROXY TCP4 127.0.0.17 %s 12345 %d", tests.DefaultSourceIP.String(), t.Port("smtp")))
153 conn.SMTPNegotation("localhost", nil, nil)
154 conn.Writeln("MAIL FROM:<testing@one.maddy.test>")
155 conn.ExpectPattern("550 *")
156 conn.Writeln("QUIT")
157 conn.ExpectPattern("221 *")
158}
159
160func TestCheckSPF(tt *testing.T) {
161 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