Commit c574e69124bb7dffba642d4dc2618b242c599491

Authored by Antonio Terceiro
1 parent 548fd9e6
Exists in master and in 90 other branches 3.x, add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup, backup_not_prod, cdtc_configuration, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev-lappis, dev_env_minimal, disable_email_dev, docs, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, performance, prezento, r3, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_backup_emails, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, stable-devel, support_docs, syslog, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

DNS tests/doc: include SPF data

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