Commit c574e69124bb7dffba642d4dc2618b242c599491
1 parent
548fd9e6
Exists in
master
and in
67 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 | email_subject_prefix: '[spb|dev]' |
| 9 | 9 | lists_hostname: listas.dev.softwarepublico.gov.br |
| 10 | 10 | lists_admin: paulo@softwarelivre.org |
| 11 | -relay_hostname: relay.dev.softwarepublico.gov.br | |
| 12 | 11 | from_address: noreply@dev.softwarepublico.gov.br |
| 13 | 12 | relay_hostname: relay.dev.softwarepublico.gov.br |
| 14 | 13 | relay_ip: 189.9.151.44 |
| 15 | 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 | 9 | email_subject_prefix: '[spb]' |
| 10 | 10 | lists_hostname: listas.homologa.softwarepublico.gov.br |
| 11 | 11 | lists_admin: nayanne.bonifacio@planejamento.gov.br |
| 12 | +from_address: noreply@homologa.softwarepublico.gov.br | |
| 12 | 13 | relay_hostname: relay.homologa.softwarepublico.gov.br |
| 13 | 14 | relay_ip: 189.9.151.66 |
| 14 | 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 | 29 | local hostname="$2" |
| 30 | 30 | local results="$(host $ip)" |
| 31 | 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 | 42 | test_dns_web() { |
| ... | ... | @@ -60,7 +67,14 @@ test_reverse_dns_relay() { |
| 60 | 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 | 79 | if [ "$1" = '--doc' ]; then |
| 66 | 80 | check_hostname() { |
| ... | ... | @@ -78,13 +92,19 @@ if [ "$1" = '--doc' ]; then |
| 78 | 92 | echo " - $1" |
| 79 | 93 | echo " - ${2}." |
| 80 | 94 | } |
| 95 | + check_spf() { | |
| 96 | + echo " * - TXT (SPF: \"v=spf1 ...\")" | |
| 97 | + echo " - $1 " | |
| 98 | + echo " - include:${2} " | |
| 99 | + } | |
| 81 | 100 | header() { |
| 101 | + local aponta="${2:-Aponta para}" | |
| 82 | 102 | echo '.. list-table::' |
| 83 | 103 | echo ' :header-rows: 1' |
| 84 | 104 | echo |
| 85 | 105 | echo ' * - Tipo' |
| 86 | 106 | echo ' - Entrada' |
| 87 | - echo ' - Aponta para' | |
| 107 | + echo " - $aponta" | |
| 88 | 108 | } |
| 89 | 109 | footer() { |
| 90 | 110 | echo |
| ... | ... | @@ -106,7 +126,10 @@ if [ "$1" = '--doc' ]; then |
| 106 | 126 | test_reverse_dns_relay |
| 107 | 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 | 135 | else | ... | ... |