(tt *testing.T)
| 114 | } |
| 115 | |
| 116 | func 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 | |
| 160 | func TestCheckSPF(tt *testing.T) { |
| 161 | tt.Parallel() |
nothing calls this directly
no test coverage detected