Commit c574e69124bb7dffba642d4dc2618b242c599491
1 parent
548fd9e6
Exists in
master
and in
90 other branches
DNS tests/doc: include SPF data
Showing
3 changed files
with
30 additions
and
7 deletions
Show diff stats
config/dev/config.yaml
@@ -8,8 +8,8 @@ server_email: '"Portal do Software Publico (dev)" <noreply@dev.softwarepublico.g | @@ -8,8 +8,8 @@ server_email: '"Portal do Software Publico (dev)" <noreply@dev.softwarepublico.g | ||
8 | email_subject_prefix: '[spb|dev]' | 8 | email_subject_prefix: '[spb|dev]' |
9 | lists_hostname: listas.dev.softwarepublico.gov.br | 9 | lists_hostname: listas.dev.softwarepublico.gov.br |
10 | lists_admin: paulo@softwarelivre.org | 10 | lists_admin: paulo@softwarelivre.org |
11 | -relay_hostname: relay.dev.softwarepublico.gov.br | ||
12 | from_address: noreply@dev.softwarepublico.gov.br | 11 | from_address: noreply@dev.softwarepublico.gov.br |
13 | relay_hostname: relay.dev.softwarepublico.gov.br | 12 | relay_hostname: relay.dev.softwarepublico.gov.br |
14 | relay_ip: 189.9.151.44 | 13 | relay_ip: 189.9.151.44 |
15 | external_outgoing_mail_relay: 189.9.150.53 | 14 | external_outgoing_mail_relay: 189.9.150.53 |
15 | +external_outgoing_mail_domain: serpro.gov.br |
config/homologa/config.yaml
@@ -9,8 +9,8 @@ server_email: '"Portal do Software Publico (homologação)" <noreply@homologa.so | @@ -9,8 +9,8 @@ server_email: '"Portal do Software Publico (homologação)" <noreply@homologa.so | ||
9 | email_subject_prefix: '[spb]' | 9 | email_subject_prefix: '[spb]' |
10 | lists_hostname: listas.homologa.softwarepublico.gov.br | 10 | lists_hostname: listas.homologa.softwarepublico.gov.br |
11 | lists_admin: nayanne.bonifacio@planejamento.gov.br | 11 | lists_admin: nayanne.bonifacio@planejamento.gov.br |
12 | +from_address: noreply@homologa.softwarepublico.gov.br | ||
12 | relay_hostname: relay.homologa.softwarepublico.gov.br | 13 | relay_hostname: relay.homologa.softwarepublico.gov.br |
13 | relay_ip: 189.9.151.66 | 14 | relay_ip: 189.9.151.66 |
14 | external_outgoing_mail_relay: 189.9.150.53 | 15 | external_outgoing_mail_relay: 189.9.150.53 |
15 | -alt_ssh_port: 55555 | ||
16 | -from_address: noreply@homologa.softwarepublico.gov.br | 16 | +external_outgoing_mail_domain: serpro.gov.br |
test/dns_test.sh
@@ -29,7 +29,14 @@ check_reverse_dns() { | @@ -29,7 +29,14 @@ check_reverse_dns() { | ||
29 | local hostname="$2" | 29 | local hostname="$2" |
30 | local results="$(host $ip)" | 30 | local results="$(host $ip)" |
31 | local expected=".*in-addr.arpa domain name pointer ${hostname}." | 31 | local expected=".*in-addr.arpa domain name pointer ${hostname}." |
32 | - assertTrue "Reverse DNS of $ip must be $hostname (found: $results)" "expr match '$results' '$expected\$'" | 32 | + assertTrue "Reverse DNS of $ip must be $hostname (found: $results)" "expr match '$results' 'include:$expected\$'" |
33 | +} | ||
34 | + | ||
35 | +check_spf() { | ||
36 | + domain="$1" | ||
37 | + spf_domain="$2" | ||
38 | + local results="$(host -t TXT "$domain")" | ||
39 | + assertTrue "TXT entry for $domain must have include:$spf_domain (found: $results)" "expr match '$results' 'include:$spf_domain'" | ||
33 | } | 40 | } |
34 | 41 | ||
35 | test_dns_web() { | 42 | test_dns_web() { |
@@ -60,7 +67,14 @@ test_reverse_dns_relay() { | @@ -60,7 +67,14 @@ test_reverse_dns_relay() { | ||
60 | check_reverse_dns "$config_relay_ip" "$config_relay_hostname" | 67 | check_reverse_dns "$config_relay_ip" "$config_relay_hostname" |
61 | } | 68 | } |
62 | 69 | ||
63 | -# TODO test_spf_external_relay | 70 | +if [ -n "$config_external_outgoing_mail_domain" ]; then |
71 | + test_spf_domain() { | ||
72 | + check_spf "$config_external_hostname" "$config_external_outgoing_mail_domain" | ||
73 | + } | ||
74 | + test_spf_lists() { | ||
75 | + check_spf "$config_lists_hostname" "$config_external_outgoing_mail_domain" | ||
76 | + } | ||
77 | +fi | ||
64 | 78 | ||
65 | if [ "$1" = '--doc' ]; then | 79 | if [ "$1" = '--doc' ]; then |
66 | check_hostname() { | 80 | check_hostname() { |
@@ -78,13 +92,19 @@ if [ "$1" = '--doc' ]; then | @@ -78,13 +92,19 @@ if [ "$1" = '--doc' ]; then | ||
78 | echo " - $1" | 92 | echo " - $1" |
79 | echo " - ${2}." | 93 | echo " - ${2}." |
80 | } | 94 | } |
95 | + check_spf() { | ||
96 | + echo " * - TXT (SPF: \"v=spf1 ...\")" | ||
97 | + echo " - $1 " | ||
98 | + echo " - include:${2} " | ||
99 | + } | ||
81 | header() { | 100 | header() { |
101 | + local aponta="${2:-Aponta para}" | ||
82 | echo '.. list-table::' | 102 | echo '.. list-table::' |
83 | echo ' :header-rows: 1' | 103 | echo ' :header-rows: 1' |
84 | echo | 104 | echo |
85 | echo ' * - Tipo' | 105 | echo ' * - Tipo' |
86 | echo ' - Entrada' | 106 | echo ' - Entrada' |
87 | - echo ' - Aponta para' | 107 | + echo " - $aponta" |
88 | } | 108 | } |
89 | footer() { | 109 | footer() { |
90 | echo | 110 | echo |
@@ -106,7 +126,10 @@ if [ "$1" = '--doc' ]; then | @@ -106,7 +126,10 @@ if [ "$1" = '--doc' ]; then | ||
106 | test_reverse_dns_relay | 126 | test_reverse_dns_relay |
107 | footer | 127 | footer |
108 | 128 | ||
109 | - # FIXME test_spf_external_relay | 129 | + header 'SPF' 'Deve conter' |
130 | + test_spf_domain | ||
131 | + test_spf_lists | ||
132 | + footer | ||
110 | 133 | ||
111 | ) | 134 | ) |
112 | else | 135 | else |